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()
z1=s.count("AB")
z2=s.count("BA")
z3=s.count("ABA")
z4=s.count("BAB")
if z3+z4>=2:
    print("YES")
elif z3==0 and z4==0:
    if z1>0 and z2>0:
        print("YES")
    else :
        print("NO")
else :
    z1-=1
    z2-=1
    if z1>0 or z2>0:
        print("YES")
    else :
        print("NO")