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.
x=str(input())
b=x.split("AB")
# print(b)
if len(b)==1:
    print("NO")
else:
    check=0
    if b[0]=="": #take the second
        check=+1
    elif b[1]=="": #take the first
        check+=2
    if check==1:
        strings=""
        strings+=b[1]
        BA_split=strings.split("BA")
        if len(BA_split)>1:
            print("YES")
        else:
            print("NO")
    if check==2:
        strings=""
        strings+=b[0]
        BA_split=strings.split("BA")
        if len(BA_split)>1:
            print("YES")
        else:
            print("NO")