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 = list(map(lambda q:str(q), input()))
l=len(s)
t=0
c=0
mate=1
zaur=1
t=[]
v=[]
for i in range(l-1):
    if s[i]=='A' and s[i+1]=="B":
        t.append(i)
        t.append(i+1)
    elif s[i]=='B' and s[i+1]=="A" and zaur==1:
        v.append(i)
        v.append(i+1)
#print(t)
#print(v)
tl=len(t)
vl=len(v)
q=abs(tl-vl)
if tl==0 or vl==0:
    print('NO')
elif tl==2 and vl==2 and (t[0]==v[1] or v[0]==t[1]):
    print('NO')
elif q>=2:
    print('YES')
elif tl>=4 and vl>=4:
    print('YES')
elif tl==2 and vl==2 and(t[0]!=v[0],v[1] and t[1]!=v[0],v[1] ):
    print('YES')
else:
    print('YES')
