You are given string *s*. Your task is to determine if the given string *s* contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
The only line of input contains a string *s* of length between 1 and 10<sup class="upper-index">5</sup> consisting of uppercase Latin letters.
string = [char for char in input()]
AB = False
BA = False
double = False
another = False
for i in range(len(string)):
    if string[i] == "A":
        if (i > 0 and string[i-1] == "B") and (i < len(string)-1 and string[i+1] == "B"):
            AB = True
            BA = True
            if double == True:
                another = True
            double = True
        elif i < len(string)-2 and string[i+1] == "B" and string[i+2] == "A":
            AB = True
            BA = True
            if double == True:
                another = True
            double = True
        elif i > 0 and string[i-1] == "B":
            BA = True
        elif i < len(string)-1 and string[i+1] == "B":
            AB = True
if (AB and BA) and not (double and not another):
    print("YES")
else:
    print("NO")