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.
# ho jaana accept 
s=input()
n=len(s)
ct1=0
ct11=0
ct2=0
n1=0
n2=0
for i in  range(n-1):
    if s[i]=="A" and s[i+1]=="B":
        ct1+=1
        n1=i+2
        break
if ct1==1:
    for j in range(n1,n-1):
        if s[j]=="B" and s[j+1]=="A":
            ct2+=1
            break
for i1 in  range(n-1):
    if s[i1]=="B" and s[i1+1]=="A":
        ct11+=1
        n2=i1+2
        break
if ct11==1:
    for j1 in range(n2,n-1):
        if s[j1]=="A" and s[j1+1]=="B":
            ct2+=1
            break        
if ct2>=1:
    print("YES")        
else:
    print("NO")