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()

start = 0
d = {"AB":0, "BA":0}

for end in range(len(s)):
    
    if end >= 2:
        start += 1
    
    if s[start: end+1] in d:
        d[s[start: end+1]] = (start, end)
    # print(s[start: end+1], start, end)
    
    if d["AB"] != 0 and d["BA"] != 0:
        if d["AB"][0] != d["BA"][0] and d["AB"][1] != d["BA"][0] and d["AB"][0] != d["BA"][1] and d["AB"][1] != d["BA"][1]:
            print("YES")
            exit()

if d["AB"] != 0 and d["BA"] != 0:
        if d["AB"][0] != d["BA"][0] and d["AB"][1] != d["BA"][0] and d["AB"][0] != d["BA"][1] and d["AB"][1] != d["BA"][1]:
            print("YES")
            exit()
      
print("NO")

    
    