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()
l1,l2 = [],[]
for i in range(1,len(s)):
    if s[i-1]=='A' and s[i]=='B':
        l1.append(i-1)
    if s[i-1]=='B' and s[i]=='A':
        l2.append(i-1)

if l1==[] or l2==[]: print('NO')
else:
    x,y,f = l2[0],l2[len(l2)-1],0
    for i in l1:
        if abs(i-x)>1 or abs(i-y)>1:
            print('YES'); f=1; break
        
    if not f: print('NO')