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.
 
#import io, os, sys
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#print = lambda x: sys.stdout.write(str(x) + "\n")
    
II = lambda: int(input())
MII = lambda: map(int, input().split())
LMII = lambda: list(MII())
#SLMII = lambda: sorted(LMII())

s = input()
n = len(s)
fAB = fBA = False

pr = None
for ch in s:
    if not fAB and pr == 'A' and ch == 'B':
        fAB = True
        pr = None
    elif not fBA and pr == 'B' and ch == 'A':
        fBA = True
        pr = None
    else:
        pr = ch

print('YES' if fAB and fBA else 'NO')
    