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

public class Codeforces implements Runnable {
    private BufferedReader br = null;
    private PrintWriter pw = null;
    private StringTokenizer stk = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(new Codeforces()).run();
    }

    public void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        /*try {
            pw = new PrintWriter("output.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }*/
        solver();
        pw.close();
    }

    private void nline() {
        try {
            if (!stk.hasMoreTokens()) {
                stk = new StringTokenizer(br.readLine());
            }
        } catch (IOException e) {
            throw new RuntimeException("KaVaBUnGO!!!", e);
        }
    }

    private String nstr() {
        while (!stk.hasMoreTokens()) {
            nline();
        }
        return stk.nextToken();
    }

    private int ni() {
        return Integer.valueOf(nstr());
    }

    private long nl() {
        return Long.valueOf(nstr());
    }

    private double nd() {
        return Double.valueOf(nstr());
    }

    private BigInteger nbi() {
        return new BigInteger(nstr());
    }

    String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
        }
        return null;
    }

    class Card implements Comparable<Card> {
        int pos;
        int val;

        public Card(int pos, int val) {
            this.pos = pos;
            this.val = val;
        }

        public int getPos() {
            return pos;
        }

        public void setPos(int pos) {
            this.pos = pos;
        }

        public int getVal() {
            return val;
        }

        public void setVal(int val) {
            this.val = val;
        }

        @Override
        public int compareTo(Card o) {
            if (o.val > this.val) {
                return 1;
            }
            if (o.val < this.val) {
                return -1;
            }
            return 0;
        }
    }


    private void solver() {
        String s = nstr();
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> b = new ArrayList<>();
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B') {
                a.add(i);
            }
            if (s.charAt(i) == 'B' && s.charAt(i + 1) == 'A') {
                b.add(i);
            }
        }
        for (int curA : a) {
            for (int curB : b) {
                if (Math.abs(curA - curB) > 1) {
                    System.out.println("YES");
                    exit();
                }
            }
        }
        System.out.println("NO");

    }


    private void bad() {
        System.out.println("No");
        exit();
    }

    private void good() {
        System.out.println("Yes");
        exit();
    }

    void exit() {
        pw.close();
        System.exit(0);
    }
}
