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.
def contains_aba_ba(s):
   # Step 1: Check if the string is empty
   if not s:
       return "NO"

   # Step 2: Split the string into individual characters
   characters = list(s)

   # Step 3: Check if the string contains the substring "AB"
   if "AB" not in "".join(characters):
       return "NO"

   # Step 4: Check if the string contains the substring "BA"
   if "BA" not in "".join(characters):
       return "NO"

   # Step 5: If both substrings are present, return "YES"
   return "YES"
   
s = input()
print(contains_aba_ba(s))