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.
word = input()  #we read a word

index = 0
ab = False
ba = False
comodin = False
while(True):
    if(index >= len(word)-1):
        print("NO")
        break
    if(comodin == False and index < len(word)-2 and ((word[index] == 'a' and word[index+1] == 'b' and word[index+2] == 'a') or (word[index] == 'b' and word[index+1] == 'a' and word[index+2] == 'b'))):
        comodin = True
        index += 2
    else:
        if(word[index]=='a' and word[index+1] == 'b'):
            ab = True
        if(word[index] == 'b' and word[index+1] == 'a'):
            ba = True
    if((ab == True and ba == True) or (comodin == True and (ba == True or ab == True))):
        print("YES")
        break
    index += 1
