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(set([i,i+1]))
    elif s_t == 'BA':
        s_ba.append(set([i,i+1]))
        
diff1 = set().union(*s_ab) - set().union(*s_ba)
diff2 = set().union(*s_ba) - set().union(*s_ab)

checker_1 = False
d1_list = list(diff1)
for i in range(len(d1_list) - 1):
    if d1_list[i+1] - d1_list[i] == 1:
        checker_1 = True
        break

checker_2 = False
d2_list = list(diff2)
for i in range(len(d2_list) - 1):
    if d2_list[i+1] - d2_list[i] == 1:
        checker_2 = True
        break

print('YES' if checker_1 & checker_2 else "NO")