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()
string_len = len(string)
s_ab = []
s_ba = []
for i in range(string_len-1):
    s_t = string[i:2+i]
    if s_t == 'AB': 
        s_ab.append(i + i+1)
    elif s_t == 'BA':
        s_ba.append(i + i+1)
        
if len(s_ab) == 0 or len(s_ba) == 0:
    print('NO')
else:
    ans = (max(s_ab) - min(s_ba) > 2) or (max(s_ba) - min(s_ab) > 2)
    print('YES' if ans else 'NO')