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()]
is_found, a, b, c = False, False, False, 0
for i in s:
    if not a and not b and i == 'A':
        a = True
    if a and not b:
        if i == 'B':
            c += 1
        if i != 'A':
            a = False
        continue

    if not a and not b and i == 'B':
        b = True
    if b and not a:
        if i == 'A':
            c += 1
        if i != 'B':
            b = False

    if c == 2:
        is_found = True
        break

print('YES' if is_found or c == 2 else 'NO')
