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.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
 
public class Main
{
    
    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	



    public static void main(String[] args)
    {
        
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        String s = sc.rs();
        if(s.contains("AB") &&  s.substring(s.indexOf("AB")+2).contains("BA") || s.contains("BA")  && s.substring(s.indexOf("BA")+2).contains("AB"))
        w.println("YES");
        else
        w.println("NO");
        
       
       
        
       
        
        
        
           
        
       
           
         
          
        /*
        int x = sc.ni();
        int y = sc.ni();
        String [][]arr = new String[x+2][y+2];
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                arr[i][j] = sc.rs();
            }
        }
        int c = 0;
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                if(arr[i][j].equals("S"))
                {
                    if(arr[i-1][j].equals("W") ||arr[i+1][j].equals("W")||arr[i][j-1].equals("W")||arr[i][j+1].equals("W"))
                    c++;
                }
            }
        }
        if(c != 0)
        w.println("No");
        else
        {
            for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                if(arr[i][j].equals("S"))
                {
                    if(arr[i-1][j].equals("."))
                    arr[i-1][j].replace(".","D");
                    
                    if(arr[i+1][j].equals("."))
                    arr[i+1][j].replace(".","D");
                    
                    if(arr[i][j+1].equals("."))
                    arr[i][j+1].replace(".","D");
                    
                    if(arr[i][j-1].equals("."))
                    arr[i][j-1].replace(".","D");
                    
                    
                }
            }
        }
        w.println("Yes");
        
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                w.print(arr[i][j]);
                
            }
            w.println();
        }
        }
        
        */
        
        
        /*
        118B
        int x = sc.ni();
        int res = x*2;
        String [][]arr = new String[res+ 1][res+1];
        
        for(int i=0;i<=x*2;i++)
        {
            for(int j=x-i;j<=x+i;j++)
            {
                if(j <= x)
                    arr[i][j] = ips(i+j-x);
                    else
                     arr[i][j] = ips(2*x -i - j);
                
            }
            
        }
        for(int i=0;i<=x*2;i++)
        {
            for(int j=0;j<=x*2;j++)
            {
                w.print(arr[i][j] + " ");
                
            }
            w.println();
        }
    */
       
        
        
        
          
       
       
      
       
        
        
        
           
        
       
           
           
        
        
        
    
        w.close();
        

        
    } 
    /*
    static boolean is(int p,int x,int y)
    {
        int flag = 0;
        
            for(int j=2;j<=p;j++)
            {
                if(x % j == 0)
                {
                    flag = 1;
                    break;
                }
                else 
                continue;
                
            }
            
        if(flag == 1)
        return false;
        else
        return true;
        
    }
    */
    static int binarysearch(int []arr,int p,int n)
    {
        
        int st = 0;
        int end = n-1;
        int mid = (st + end)/2;
        int temp = 0;
        while(st <= end)
        { 
            mid = (st + end)/2;
        
            if(p >= arr[mid])
            {
                st = mid+1;
                
            }
            else if(p < arr[mid])
            {
                end = mid-1;
                
            }
            temp = st;
            
            
        }
        
        return temp;
    }
    
   
    static class Student
    {
        int start;
        int end;
        int index;
        Student(int start,int end,int index)
        {
            this.start = start;
            this.end = end;
            this.index = index;
            
        }
        
    }
    static int lis(int arr[],int n)
    {
          int lis[] = new int[n];
          int i,j,max = 0;
 
          /* Initialize LIS values for all indexes */
           for ( i = 0; i < n; i++ )
              lis[i] = 1;
 
           /* Compute optimized LIS values in bottom up manner */
           for ( i = 1; i < n; i++ )
              for ( j = 0; j < i; j++ ) 
                         if ( arr[i] > arr[j] && lis[i] <= lis[j])
                    lis[i]++;
 
           /* Pick maximum of all LIS values */
           for ( i = 0; i < n; i++ )
              if ( max < lis[i] )
                 max = lis[i];
 
            return max;
    }
    
    
    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}
	
    
					 
}
