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()
s=s+'000'
s='0'+s
ab=False
ba=False
consecab=False
consecba=False
curstart=None
curlength=0
for i in range(1,len(s)-3):
    if s[i]!='B' and s[i+1]=='A' and s[i+2]=='B' and s[i+3]!='A':
        ab=True
    if s[i]!='A' and s[i+1]=='B' and s[i+2]=='A' and s[i+3]!='B':
        ba=True
    if s[i]=='A' and s[i+1]=='B':
        consecab=True
    if s[i]=='B' and s[i+1]=='A':
        consecba=True
    if (s[i-1]=='A' and s[i]=='B') or (s[i-1]=='B' and s[i]=='A'):
        curlength+=1
    else:
        if curlength>=5:
            break
        elif s[i]=='A' or s[i]=='B':
            curlength=1
        else:
            curlength=0
if (ab and consecba) or (ba and consecab) or (ab and ba) or curlength>=5:
    print('YES')
else:
    print('NO')

    
    





