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".
# Take a string as input
# Find every occurence of "AB"
# for every one you find,
# check for occurrences of "BA"
#
# Make a function to simplify the string
# Replace all the long non "ABs" between "AB"s or "BA"s
# with just one "X"


def simplify(seq):
    """shorten the sequence by removing all the
       letters between A and B except 1"""
    # if the current letter is "A" or "B"
    #   > add it.
    # If the current letter is not "A" or "B":
    #   > check if the next letter is "A" or "B"
    #   > if it is "A" or "B":
    #       * add it
    #   > if not:
    #       * ignore
    new_seq = []
    for i in range(len(seq)-1):
        if seq[i] == "A" or seq[i] == "B":
            new_seq.append(seq[i])
        else:
            if seq[i+1] == "A" or seq[i+1] == "B":
                new_seq.append(seq[i])
            else:
                continue
    # Manually add the last element XD
    new_seq.append(seq[-1])
    return "".join(new_seq)


def is_valid(seq):
    if "AB" in seq and "BA" in seq:
        return True
    return False


def find_occurrence(seq, depth):
    """ Check if seq contains non-overlapping 'AB' and 'BA' """
    # If depth is TWO, check for "BA"
    if depth == 2:
        for i in range(len(seq)):
            if seq[i:i+2] == "BA":
                return True
        return False

    # If depth is ONE, check for "AB"
    # Find each occurrence of "AB"
    # and call the function recursively on the new string
    else:
        # iterate through the list. check for 'AB'
        # for every 'AB' found, replace 'AB' with 'XX'
        # and call function recursively
        for i in range(len(seq)):
            if seq[i:i+2] == "AB":
                new_seq = seq[:i] + "XX" + seq[i+2:]

                # if it's already been found, stop the func
                found = find_occurrence(new_seq, 2)
                if found:
                    return True


your_string = input()

your_string = simplify(your_string)

if is_valid(your_string):
    contains_substrings = find_occurrence(your_string, 1)
    if contains_substrings:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
