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.
import sys
def input(): return sys.stdin.readline().strip()
def getints(): return map(int,sys.stdin.readline().strip().split())

l = [['A','B'],['B','A']]
s = list(input())
w = len(s)
c = 0
i = 0
while i < w:
    if s[i:i+2] in l:
        l.remove(s[i:i+2])
        i += 1
        c += 1
    if c == 2: break
    i += 1
print('NO' if len(l) else 'YES')