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.
txt = input('')
count = 0
string = [i for i in txt]

if len(string)%2 != 0:
    pass
else:
    string.append('C')
    

for i in range(1,len(string),2):
    if string[i] == 'A':
        if string[i+1] == 'B' or string[i-1] == 'B':
            print('here')
            count += 1
        else:
            pass
    elif string[i] == 'B':
        if string[i+1] == 'A' or string[i-1] == 'A':
            print('here')
            count += 1
        else:
            pass

if count == 2:
    print('YES')
else:
    print('NO')
        
            
    
    
            
