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 = [i for i in input()]
found_AB, found_BA, a, b = False, False, False, False
for i in s:

    if not found_AB:
        if not a and not b and i == 'A':
            a = True
        if a and not b:
            if i == 'B':
                found_AB = True
                #print('found AB')
            if i != 'A':
                a = False
            continue

    if not found_BA:
        if not a and not b and i == 'B':
            b = True
        if b and not a:
            if i == 'A':
                found_BA = True
                #print('found BA')
            if i != 'B':
                b = False

    if found_AB and found_BA:
        break

print('YES' if found_AB and found_BA else 'NO')
