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".
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

s = input()
#print(s)
n = len(s)
if n < 4:
	print("NO")
	exit()


def check(a):
	ind = -1
	ind3 = -1
	for i in range(n-1):
		if s[i] == a[0] and s[i+1] == a[1]:
			ind3 = i
			ind = i+1
			break
	ind2 = -1
	ind4 = -1
	k = i+1
	for i in range(k,n-1):
		if s[i] == a[1] and s[i+1] == a[0]:
			ind4 = i+1
			ind2 = i
	#print(ind,ind3,ind2,ind4)
	if ind == -1 or ind2 == -1 or ind3 == -1 or ind4 == -1:
		return False
	else:
		if ind != ind2 and ind3 != ind4:
			return True
		else:
			return False

if check("AB") or check("BA"):
	print("YES")
else:
	print("NO")
	





