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

public class A{
	
	static String s;
	static boolean t1[],t2[];
	static void MainMethod()throws Exception{
		s=reader.readNextLine();
		int n=s.length(),i,j,k;
		t1=new boolean[n+1];Arrays.fill(t1, false);
		t2=new boolean[n+1];Arrays.fill(t2, false);
		int ab=0, ba=0;
		for (i=1;i<n;i++){
			t1[i]=((s.charAt(i-1)=='A')&&(s.charAt(i)=='B'));
			t2[i]=((s.charAt(i-1)=='B')&&(s.charAt(i)=='A'));
			if (t1[i]==true) ab++;
			if (t2[i]==true) ba++;
		}
		if (ab>=2 && ba>=2) {
			printer.print("YES");
			halt();
		}
		if (ab<ba){
		for (i=1;i<n;i++) if (t1[i]==true)
			for (j=1;j<n;j++) if ((t2[j]==true)&&(Math.abs(i-j)>=2)){
				printer.print("YES");
				halt();
			}
		}
		else{
		for (i=1;i<n;i++) if (t2[i]==true)
			for (j=1;j<n;j++) if ((t1[j]==true)&&(Math.abs(i-j)>=2)){
				printer.print("YES");
				halt();
			}
		}
		printer.print("NO");
	}
	public static void main(String[] args)throws Exception{
		MainMethod();
		printer.close();
	}
	
	static void halt(){
		printer.close();
		System.exit(0);
	}
	static PrintWriter printer=new PrintWriter(new OutputStreamWriter(System.out));
	static class reader{
		static BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
		static StringTokenizer token=new StringTokenizer("");
		static String readNextLine() throws Exception{
			return bReader.readLine();
		}
		static String next() throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return token.nextToken();
		}
		static int nextInt()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Integer.parseInt(token.nextToken());
		}
		static long nextLong()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Long.parseLong(token.nextToken());
		}
		static double nextDouble()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Double.parseDouble(token.nextToken());
		}
	}
}
