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.
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

s = list(input().rstrip())
u = [[65, 66], [66, 65]]
ans = "NO"
for _ in range(2):
    i, j = 0, 0
    while i < 2 and j < len(s) - 1:
        x, y = u[i]
        if s[j] == x and s[j + 1] == y:
            i += 1
            j += 1
        j += 1
    if i == 2:
        ans = "YES"
        break
    u[0], u[1] = u[1], u[0]
print(ans)