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.
# Read the input string
s = input()

# Check if the string contains "AB" and "BA"
if "AB" in s and "BA" in s:
  # If the string contains "AB" and "BA", check if they are non-overlapping
  if s.index("AB") + 2 < s.index("BA") or s.index("BA") + 2 < s.index("AB"):
    # If the substrings are non-overlapping, print YES
    print("YES")
  else:
    # If the substrings are overlapping, print NO
    print("NO")
else:
  # If the string does not contain "AB" and "BA", print NO
  print("NO")