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.
n = input()
n = [x for x in n]

# print(n)


res1 =0
res2 =0
for i in range(len(n)-1):
    if n[i] == "A":
        if n[i+1] == "B":
            res1 +=1
            n[i+1] = "0"
            
    if n[i] == "B":
        if n[i+1] == "A":
            res2 +=1
            n[i+1] = "0"

# print(n)
if res1 <1 or res2<1:
    print("NO")
else:
    print("YES")