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()
 
 
AB_POSITION = s.find("AB")
 
BA_POS= s.find("BA")
 
if AB_POSITION != -1 and BA_POS!= -1 and abs(AB_POSITION - BA_POS) > 1:#To check postion of AB and BA in string and substring is occuremore than 1 time
    print("YES") #if AB found at start point and  BA is found in last position of  string s print yes 
else:
    # Check if the positions of the substrings are reversed
    if BA_POS!= -1 and s.find("AB", BA_POS+ 2) != -1:
        print("YES")
    elif AB_POSITION != -1 and s.find("BA", AB_POSITION + 2) != -1: #it finds the ba from string and increment ab postion by
        print("YES")
    else:
        print("NO")
			  	  						 	   	  	  	 	 	