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.
x = input()
fl = 'NO'
if len(x)<4:
    if len(x) ==1:
        fl = 'NO'
    elif len(x) == 2 and (x[0] + x[1] == 'AB' or x[0]+x[1] == 'BA'):
        fl = 'YES'
    else:
        fl = 'NO'
else:
    if 'AB' in x or "BA" in x:
        fl = 'YES'
    for i in range(len(x)-3):
        if (x[i] + x[i+1] + x[i+2] =='ABA' and x[i+3] != 'B') or (x[i] + x[i+1] + x[i+2] =='BAB' and x[i+3] != 'A'):
            fl = "NO"
            break
if len(x)>3:
    if (x[-3]+x[-2]+x[-1] == 'ABA' and x[-4] != 'B') or (x[-3]+x[-2]+x[-1] == 'BAB' and x[-4] != 'A'):
        fl = 'NO'
print(fl)