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.
lab = []
lba = []

s = input()
l = len(s)

for i in range(l-1):
    if s[i] == 'A' and s[i+1] == 'B':
        lab.append((i, i+1))

for i in range(l-1):
    if s[i] == 'B' and s[i+1] == 'A':
        lba.append((i, i+1))

flag = False
for i in lab:
    for j in lba:
        if i[1] != j[0]:
            flag = True
            break
    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")
