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 = str(input())
ans = 'NO'
if 'AB' not in s and 'BA' not in s:
    ans = 'NO'
else:
    cur = 0
    while cur < len(s):
        try:
            cur = s.index('AB', cur)
            s2 = s[0:cur]+s[cur+2::]
            if 'BA' in s2:
                ans = 'YES'
                break
            else:
                cur += 1
        except:
            ans = 'NO'
            break
print(ans)