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())

import bisect
left  = lambda l,a : bisect.bisect_left(l,a)  #returns index of first value>=a
right = lambda l,a : bisect.bisect_right(l,a) #returns index of first value >a

l = [['A','B'],['B','A']]
s = list(input())
w = len(s)
ans = 0

i = 0
while i < w:
    if s[i:i+2] in l:
        if s[i+2] == s[i]:
            ans += 1
        else:
            l.remove(s[i:i+2])
            ans += 1
    if ans == 2: break
    i += 1
print('Yes' if ans == 2 else 'NO')