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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import static java.lang.Math.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        int c=0;int cc=0;
        int d=0;int dd=0;
        StringBuilder ss=new StringBuilder(s);
        
   for (int i = 0; i < ss.length()-1; i++) {
            if ((ss.charAt(i)=='B'&&ss.charAt(i+1)=='A')) {
                ss=ss.deleteCharAt(i);
                ss=ss.deleteCharAt(i);
                ss.insert(i, "m");
                c++;
                break;
            } }
   
            for (int j = 0; j < ss.length()-1; j++) {
             if ((ss.charAt(j)=='A'&&ss.charAt(j+1)=='B')) {
               d++;
               
            }
       }
          ss=new StringBuilder(s);
            for (int i = 0; i < ss.length()-1; i++) {
            if ((ss.charAt(i)=='A'&&ss.charAt(i+1)=='B')) {
                ss=ss.deleteCharAt(i);
                ss=ss.deleteCharAt(i);
                ss.insert(i, "m");
                cc++;
                break;
            } }
   
            for (int j = 0; j < ss.length()-1; j++) {
             if ((ss.charAt(j)=='B'&&ss.charAt(j+1)=='A')) {
               dd++;
               
            }
       }
       
        System.out.println((c>=1&&d>=1)||(cc>=1&&dd>=1)?"YES":"NO");
       
        
    }
    

    static int Obe(long a, long b) {
        BigInteger b1 = new BigInteger("" + a);

        BigInteger b2 = new BigInteger("" + b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    static int che(int[] w) {
        Set<Integer> list = new LinkedHashSet<>();
        for (int i = 0; i < w.length; i++) {
            list.add(w[i]);
        }

        return list.size();
    }

    private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>();

    static {
        fibCache.add(BigInteger.ZERO);
        fibCache.add(BigInteger.ONE);
    }

    public static BigInteger fib(int n) {
        if (n >= fibCache.size()) {
            fibCache.add(n, fib(n - 1).add(fib(n - 2)));
        }

        return fibCache.get(n);
    }

    static long g(long number) {
        long factorial = 0;
        for (long i = 1; i <= number; ++i) {
            factorial += i;
        }
        return factorial;

    }
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());

    }

}