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.*;
import java.util.*;

public class codeforces {
    static class pair {
        int x;
        int y;

        public pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static long sqrt(long x) {
        long s = 0, e = x, root = 0;
        while (s <= e) {
            long mid = (s + e) / 2;
            if (mid * mid == x)
                return mid;
            if (mid * mid < x) {
                root = mid;
                s = mid + 1;
            } else
                e = mid - 1;
        }
        return root;
    }

    public static long power(int a, int b) {
        if (a == 0 || b == 0)
            return 1;
        long ans = power(a, b / 2);
        ans *= ans;
        if (b % 2 == 1)
            ans *= a;
        return ans;
    }

    public static boolean isprime(long x) {
        if (x == 1)
            return false;
        if (x < 4)
            return true;
        int root = (int) Math.sqrt(x);
        for (int i = 2; i <= root; i++) {
            if (x % i == 0)
                return false;
        }
        return true;
    }

    public static long max(long a, long b) {
        return Math.max(a, b);
    }

    public static long min(long a, long b) {
        return Math.min(a, b);
    }

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder();
        PrintWriter out = new PrintWriter(System.out);
        // int t = Integer.parseInt(br.readLine());
        // while(t-->0){
            // Integer n=Integer.parseInt(br.readLine());
            // Integer[] aIntegers=new Integer[n];
            // String[] strings=br.readLine().split(" ");
            String s=br.readLine();
            String s1=s,s2=s;
            s1=s1.replaceFirst("AB","1");
            if(s1.contains("1") && s1.contains("BA"))
            str.append("YES\n");
            else{
                s2=s2.replaceFirst("BA","1");
                if(s2.contains("1") && s2.contains("AB"))
                str.append("YES\n");
                else
                str.append("NO\n");   
            }
        // }
        out.print(str);
        out.close();
    }
}
