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.
string = input()
found = False
i = 0

while i < len(string) - 1:
    if string[i:i+2] == 'AB':
        # Check if there is 'BA' substring after 'AB'
        if 'BA' in string[i+2:]:
            found = True
            break
    elif string[i:i+2] == 'BA':
        # Check if there is 'AB' substring after 'BA'
        if 'AB' in string[i+2:]:
            found = True
            break

    i += 1

print("YES" if found else "NO")
