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=str(input())
l1,l2=[],[]
overlap=True
for i in range(1,len(s)):
    pair=s[i-1]+s[i]
    if pair=="AB":
        l1.append([i-1,i])
        if l2 and l2[0][1]<i-1:
            overlap=False
            break
    if pair=="BA":
        l2.append([i-1,i])
        if l1 and l1[0][1]<i-1:
            overlap=False
            break
print("YES" if not overlap else "NO")