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.awt.image.AreaAveragingScaleFilter;
import java.io.*;
import java.util.*;

public class Main {

    static ArrayList<Integer>[] gr;
    static boolean[] was;
    static boolean[] want_h;
    static int to;
    static boolean ans;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
//        br = new BufferedReader(new FileReader(new File("input.txt")));
//        out = new PrintWriter(new File("output.txt"));
        int PUTEN = 1;
        for (int PUTIN_POMOGI = 0; PUTIN_POMOGI < PUTEN; PUTIN_POMOGI++) {
            char[] s = next().toCharArray();
            int n = s.length;
            ArrayList<Integer> ind_ab = new ArrayList<>();
            ArrayList<Integer> ind_ba = new ArrayList<>();
            int ind = 0;
            while (ind < n - 1) {
                if (s[ind] == 'A' && s[ind + 1] == 'B') {
                    ind_ab.add(ind);
                }
                if (s[ind] == 'B' && s[ind + 1] == 'A') {
                    ind_ba.add(ind);
                }
                ind++;
            }
            boolean can = false;
            for (Integer ab : ind_ab) {
                if (can) break;
                for (Integer ba : ind_ba) {
                    if (ab != ba - 1 && (ab - 1 != ba)) {
                        can = true;
                        break;
                    }
                }
            }
            if(can)out.println("YES");
            else out.println("NO");
        }
        out.close();
    }

    static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer in = new StringTokenizer("");

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


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

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static long gcd(long a, long b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    static class sort implements Comparator<point> {

        @Override
        public int compare(point o1, point o2) {
            return Integer.compare(o1.ind, o2.ind);
        }
    }

    static void dfs(int from, String want) {
        if (ans) return;
        was[from] = true;
        if (want_h[from] && want.equals("H")) ans = true;
        if (!want_h[from] && want.equals("G")) ans = true;
        for (int p : gr[from]) {
            if (!was[p]) dfs(p, want);
        }
        return;
    }
}

class point {
    int ind;
    int wight;
    int speed;

    public point(int ind, int wight, int speed) {
        this.ind = ind;
        this.wight = wight;
        this.speed = speed;
    }
}