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=input()
n=len(s)
A="AB"
B="BA"
sign=0
count=0
index=n
for i in range(n):
    if s[i]!=A[count]:
        count=0
    if s[i]==A[count]:
        count+=1
        if count==2:
            index=i+1
            break
count=0
for i in range(index,n):
    if s[i]!=B[count]:
        count=0
    if s[i]==B[count]:
        count+=1
        if count==2:
            sign=1
            break
    else:
        count=0
if sign:
    print("YES")
else:
    sign=0
    count=0
    index=n
    for i in range(n):
        if s[i]!=B[count]:
            count +=0
        if s[i]==B[count]:
            count+=1
            if count==2:
                index=i+1
                break
        else:
            count = 0
    count=0
    for i in range(index,n):
        if s[i]!=A[count]:
            count +=0
        if s[i]==A[count]:
            count+=1
            if count==2:
                sign=1
                break
        else:
            count = 0
    if sign:
        print("YES")
    else:
        print("NO")


