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".
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018 Cheran Senthilkumar
#
# This file is part of https://github.com/Cheran-Senthil/PyRival
#
# PyRival is licensed under the MIT License

from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
import sys
from atexit import register
from bisect import bisect_left, bisect_right

# import random
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    from io import BytesIO as stream
    # from cPickle import dumps
    # from Queue import PriorityQueue, Queue
else:
    from io import StringIO as stream
    from math import gcd
    # from functools import reduce
    # from pickle import dumps
    # from queue import PriorityQueue, Queue


if sys.version_info[0] < 3:
    class dict(dict):
        def items(self):
            return dict.iteritems(self)

        def keys(self):
            return dict.iterkeys(self)

        def values(self):
            return dict.itervalues(self)

    def gcd(a, b):
        """
        Calculate the Greatest Common Divisor of a and b.

        Parameters
        ----------
        a, b : int

        Returns
        -------
        int
            The greatest common divisor of the integers a and b.

        """
        while b:
            a, b = b, a % b
        return a

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip


def sync_with_stdio(sync=True):
    """
    Sets whether the standard Python streams are allowed to buffer their I/O.

    Parameters
    ----------
    sync : bool, optional
        The new synchronization setting. Default is True.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))


def main():
    """Dattebayo!"""
    s = input()
    if 'AB' not in s:
        print('NO')
        exit()
    if 'BA' not in s:
        print('NO')
        exit()

    s1 = s.split('AB')
    s2 = s.split('BA')

    first1 = s1[0]
    first2 = s2[0]

    rest1 = 'AB'.join(s1[1:])
    rest2 = 'BA'.join(s2[1:])

    if ('BA' in rest1) or ('BA' in first1):
        print('YES')
        exit()

    if ('AB' in rest2) or ('AB' in first2):
        print('YES')
        exit()

    print('NO')


if __name__ == '__main__':
    # Will only be executed when this module is run directly.
    sync_with_stdio()

    if 'PyPy' in sys.version:
        from _continuation import continulet

        def bootstrap(c):
            callable, arg = c.switch()
            while True:
                to = continulet(lambda _, f, x: f(x), callable, arg)
                callable, arg = c.switch(to=to)

        c = continulet(bootstrap)
        c.switch()

        main()

    else:
        import threading

        sys.setrecursionlimit(2097152)
        threading.stack_size(134217728)
        main_thread = threading.Thread(target=main)
        main_thread.start()
        main_thread.join()
