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.LinkedList;
import java.util.Scanner;

public class TwoSubstrings {
		
		/*
		 * 	time limit per test2 seconds
			memory limit per test256 megabytes
			inputstandard input
			outputstandard output
		 */
		
		// http://codeforces.com/contest/550/problem/A
		
	
		
		public static void main(String[]args) {
			LinkedList<String> substrings = new LinkedList<>();
			Scanner scan = new Scanner(System.in);
			String input =  scan.nextLine();
			
			System.out.println(forcaBruta(substrings,input));
			
			
		}

		//ABA
		//ABAXXXAB YES
		//ABBA YES
		
		//SKDSKDJABSDBADKFJDK
		//CBBABDDBBADAC YES
		private static String forcaBruta(LinkedList<String> substrings , String input) {
			
			int tamanhoString = input.length();
				// tamanho da string

			substrings.clear(); substrings.add("AB"); substrings.add("BA");
			// sao add na lista 
			
			boolean temCombinacaoTripla = false;
			
			for(int x = 0 ; x < tamanhoString - 1 ; x++) {
	
				boolean contemSobreposicao = false; //non-overlapping
				
				for( String sub : substrings) {
					// verifica igualdade sub e input.substring
					
					int posInicial = x;
					int posFinal = posInicial + sub.length();
					
					if(!contemSobreposicao) 
					{
						// nao contem sobreposicao (overlapping)
						if( (tamanhoString - 1) > (posFinal + 1) && (input.substring( x , posFinal + 1 ).equals("ABA") || input.substring( x , posFinal + 1 ).equals("BAB")) )
							// verifica ABA
						{
							
							if(temCombinacaoTripla) return "YES";
							temCombinacaoTripla = true;
							contemSobreposicao = true;
							x = x + 2 ;
							
							
						}//fim if
						else if( sub.equals( input.substring( x , posFinal ) ) )
						{
								if(temCombinacaoTripla)
								{
									return "YES";
								}
								else 
								{
									contemSobreposicao = true;
									substrings.remove(sub); x++;
								}	
						}//fim else if
						
					}//fim if	
					
					// nao faz nada =T
					
				}//fim foreach
			}//fim for x++
				

			if(substrings.isEmpty()) 
				return "YES";
			else 
				return "NO";
		}// fim metodo
				
	}// fim classe
