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.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        FastReader fr = new FastReader();
        FastWriter fw = new FastWriter();
        String s = fr.nextString();
        boolean ba = false;
        boolean ab = false;
        boolean ans = false;
        for (int i = 1; i < s.length(); i++) {
            if (!ba && s.charAt(i) == 'A' && s.charAt(i - 1) == 'B') {
                ba = true;
                i++;
            } else if (ba && s.charAt(i) == 'B' && s.charAt(i - 1) == 'A') {
                ab = true;
            }
        }
        ans = ba && ab;
        ba = false;
        ab = false;
        for (int i = 1; i < s.length(); i++) {
            if (!ab && s.charAt(i) == 'B' && s.charAt(i - 1) == 'A') {
                ab = true;
                i++;
            } else if (ab && s.charAt(i) == 'A' && s.charAt(i - 1) == 'B') {
                ba = true;
            }
        }
        ans |= ba && ab;
        if (ans)
            fw.println("YES");
        else
            fw.println("NO");
    }

}


class FastReader {
    public FastReader() {
    }

    public FastReader(String fileName) throws FileNotFoundException {
        this.br = new BufferedReader(new FileReader(fileName));
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;

    String nextString() throws IOException {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

class FastWriter {
    public FastWriter() {
    }

    public FastWriter(String fileName) throws IOException {
        this.bw = new BufferedWriter(new FileWriter(fileName));
    }

    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    void print(Object o) throws IOException {
        bw.write(o.toString());
        bw.flush();
    }

    void println(Object o) throws IOException {
        print(o.toString() + "\n");
    }

    void printSp(Object o) throws IOException {
        print(o.toString() + " ");
    }
}