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.
string = input()
if string.count("AB")==0 or string.count("BA")==0:
    print("NO")
elif string.count("AB")==1 and string.count("BA")==1 :
    if "AB" in string and "BA" in string and abs(string.index("BA")-string.index("AB"))!=1:
        print("YES")
    else:
        print("NO")           
else:
    index1 , index2 =0,0
    if string.index("AB") < string.index("BA"):
        index1 = 0
        index2 = 2
    else:
        index1 = 2
        index2 = 0
    if "AB" in string and "BA" in string and abs(string.index("BA",index2)-string.index("AB",index1))!=1:
        print("YES")
    else:
        print("NO")