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 compute_prefix_function(p):
    """
    Вычисляет префикс функцию паттерна p
    :param p: паттерн для kmp
    :return: преикс функцию для p
    """
    s = [0] * len(p)
    border = 0  # текущая граница
    for i in range(1, len(p)):
        while border > 0 and p[i] != p[border]:
            border = s[border - 1]
        if p[i] == p[border]:
            border += 1
        else:
            border = 0
        s[i] = border
    return s


def kmp(p, t, sep='$'):
    """
    находит индексы всех вхождений паттерна p в текст t
    :param p: паттерн
    :param t: текст
    :param sep: разделитель, который не встречается ни в p, ни в t
    :return: массив индексов всех вхождений p в t
    """
    S = '{}{}{}'.format(p, sep, t)
    s = compute_prefix_function(S)
    result = []
    for i in range(len(p), len(S)):
        if s[i] == len(p):
            result.append(i - 2 * len(p))
    return result

def exist_two_non_overlapping(first, second):
    if (not first) or (not second):
        return False
    ok = False

    for i in first:
        for j in second:
            if abs(i - j) >= 2:
                return True
    return ok


word = input()
first = kmp('AB', word)
second = kmp('BA', word)
if exist_two_non_overlapping(first, second):
    print('YES')
else:
    print('NO')