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

Input

The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.

Output

Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.

Examples

Input

ABA


Output

NO


Input

BACFAB


Output

YES


Input

AXBYBXA


Output

NO

Note

In the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".

In the second sample test there are the following occurrences of the substrings: BACFAB.

In the third sample test there is no substring "AB" nor substring "BA".
def main():
    s = input().strip()
    ab_idxs = []
    ba_idxs = []

    find_e_idxs(s, ab_idxs, 'AB')
    find_e_idxs(s, ba_idxs, 'BA')

    # print(ab_idxs, ba_idxs)

    found_two_substrings = False
    for i in range(len(ab_idxs)):
        curr_ab_idx = ab_idxs[i]
        for j in range(len(ba_idxs)):
            curr_ba_idx = ba_idxs[j]
            if curr_ba_idx + 2 <= curr_ab_idx or curr_ab_idx + 2 <= curr_ba_idx:
                found_two_substrings = True
                break

        if found_two_substrings:
            break

    print('YES' if found_two_substrings else 'NO')


def find_e_idxs(lst, idxs, e):
    """ Checks for the first two elements of `e` """
    lst_len = len(lst)
    for i in range(lst_len):
        if i + 1 < lst_len and lst[i] == e[0] and lst[i + 1] == e[1]:
            idxs.append(i)


if __name__ == '__main__':
    main()
