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.
d=str(input())
n=0
s=0
l=[]
for i in range(len(d)-1):
    l.append(d[i:i+2])

for i in range(1):
    if len(d)<=3:
        print("NO")
        break
    else:
        for i in range(len(l)):
            if i==len(l)-1:
                print("NO")
            elif l[i] == "AB":
                for j in range(i + 1, len(l)):
                    if j == len(l)-1 and i==len(l)-2:
                        print("NO")
                    elif l[j] == "BA":
                        print("YES")
                break
            elif l[i] == "BA":
                for j in range(i + 1, len(l)):
                    if j == len(l)-1 and i==len(l)-2:
                        print("NO")
                    elif l[j] == "AB":
                        print("YES")
                break
