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.
def Analiza(AB,Cad):
    Aux=Cad.replace(AB,"X",1)
    if(len(Aux)==len(Cad)):
        return False,Aux
    else:
        return True,Aux
Cad=input()
N=len(Cad)
Res1,Cad1=Analiza("AB",Cad)
if(Res1==True):
    Res2,Cad2=Analiza("BA",Cad1)
    if(Res2==True):
        print("YES")
    else:
        Res3,Cad3=Analiza("BA",Cad)
        if(Res3==True):
            Res4,Cad4=Analiza("AB",Cad3)
            if(Res4==True):
                print("YES")
            else:
                print("NO")
else:
    print("NO")
