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.
s = input()
BAB = 0
BA = 0
AB = 0

flag = False
i = 0
while(i < len(s)-2):
    sub = s[i:i+3]
    if "BAB" in sub or "ABA" in sub:
        BAB += 1
        i += 3
    elif "AB" in sub[0:2]:
        AB += 1
        i += 2
    elif "BA" in sub[0:2]:
        BA += 1
        i += 2
    else:
        i += 1
    
    if (BA>0 and AB>0) or (BAB>0 and AB>0) or (BAB>0 and BA>0) or (BAB > 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")