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()
yes = 0
yes2 = 0
yes3 = 1
for i in range(len(s)-1):
  temp = s[i] + s[i+1]
  if temp == 'AB':
    yes = 1
    if i == len(s)-1 or i == 0:
      continue
    temp2 = s[i-1] + s[i]
    temp3 = s[i] + s[i+1]
    if temp2 == 'BA' or temp3 == 'BA':
      yes3 = 0
      break
  if temp == 'BA':
    yes2 = 1
if yes3 == 0 or (yes == 0 and yes2 == 0):
  print('NO')
else:
  print('YES')