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.
s = input()
kol = 0
kol2 = 0
m = []
m2 = []
for i in range(len(s)):
    if i % 2 == 0:
        m.append(s[i])
    else:
        m2.append(s[i])
for i in range(len(s)//2):
    if m[i] == 'A' and m2[i] == 'B':
        kol += 1
    if m[i] == 'B' and m2[i] == 'A':
        kol2 += 1
if kol > 0 and kol2 > 0:
    print("YES")
else:
    print("NO")
