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 sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true=True
false=False
null=None
tcid=0
tcmax=99999999
def compute(val, func): return func(val)
def seq(lo,hi,step=1): 
 return range(lo,hi+1,step)
def sround(val,nd):
 return f'{val:.{nd}f}'
def ceil(a,b):
 ans=a//b
 if a%b!=0: ans+=1
 return ans
def perr(*args,**kwargs): print(*args,file=sys.stderr,**kwargs)
def line():
 ln=sys.stdin.readline().strip()
 #perr(ln)
 if ln=='': sys.exit()
 return ln
def lines(n): return [line() for i in range(n)]
def split(ln=None): return (ln or line()).split()
def num(str=None):
 str=str or line()
 return float(str) if '.' in str else int(str)
def nums(o=None):
 if o is not None:
  if isinstance(o, int): o=lines(o)
  elif isinstance(o, str): o=split(o)
 return list(map(num, o or split()))
#
#help("sys.modules")
"""
ceil(a,b) sround(val,nd) true false null
num(?) nums(?) split(?) lines(n) line()
perr(print) tcmax seq() compute(v,f) tcid
"""
#{#

#}#
def mainloop(tcid=1):
# {{{
 s=line()
 def aaa(aa,bb):
  ii=s.find(aa)
  if ii<0:
   return false
  jj=s.find(bb,ii+2)
  return jj>-1
 ab="AB"
 ba="BA"
 def bbb():
  return aaa(ab,ba) or aaa(ba,ab)
 yes="YES"
 no="NO"
 ans=[no,yes]
 ans=ans[bbb()]
 print(ans)
# }}}
while tcid<tcmax:
 tcid+=1
 mainloop(tcid)
"""
NOTES = .

"""
"""
PROBLEM #ID = .

"""