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 io, os, sys
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#print = lambda x: sys.stdout.write(str(x) + "\n")
    
II = lambda: int(input())
MII = lambda: map(int, input().split())
LMII = lambda: list(MII())
#SLMII = lambda: sorted(LMII())

s = input()

found = False

dic = [['B', 'A'], ['A', 'B']]
i = 0
j = 0
for ch in s:
    if ch == dic[i][j]:
        if i == 0:
            if j == 0:
                j += 1
            else:
                i = 1
                j = 0
        else:
            if j == 0:
                j = 1
        if i == 1 and j == 1:
            found = True
            break
    else:
        j = 0

  
dic = [['A', 'B'], ['B', 'A']]
i = 0
j = 0
for ch in s:
    if ch == dic[i][j]:
        if i == 0:
            if j == 0:
                j += 1
            else:
                i = 1
                j = 0
        else:
            if j == 0:
                j = 1
        if i == 1 and j == 1:
            found = True
            break
    else:
        j = 0
        
print('YES' if found else 'NO')
    