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".
# @Date    : 2016-06-23 09:42:26
# @Author  : Samandar Ravshanov (ravshanoff@protonmail.com)
# @Problem : 


import unittest

from random import randint
from sys import maxsize

class StressTest(unittest.TestCase):
	known_values = (
		# S,                    expected
		("ABA",    				"NO"),
		("BACFAB", 				"YES"),
		("AXBYBXA", 			"NO"),
		("ABBA",                "YES"),
		("ABABAB",              "YES"),
		("A",                   "NO"),
		("ABAXXXAB",            "YES"),
	)

	def test_known_cases(self):
		for S, expected in self.known_values:
			self.assertEqual(expected, NaiveSolution().twoSubs(S))

	def test_all_cases(self):	
		while True:
			break


class NaiveSolution:

	def twoSubs(self, S):
		ab_1, ba_1, i = 0, 0, 0
		ab_2, ba_2, j = 0, 0, len(S)-1

		# AB first
		while i < len(S)-1:
			ss = (S[i]+S[i+1])

			if ab_1 == 0 and ss == "AB":
				ab_1 += 1
				i  += 2
			elif ba_1 == 0 and ab_1 == 1 and ss == "BA":
				ba_1 += 1
				i  += 2
			else:
				i += 1

		# BA first
		while j > 0:
			ss = (S[j-1]+S[j])

			if ab_2 == 0 and ss == "AB":
				ab_2 += 1
				j  -= 2
			elif ba_2 == 0 and ab_2 == 1 and ss == "BA":
				ba_2 += 1
				j  -= 2
			else:
				j -= 1

		scenario_1  = (ab_1 == 1 and ba_1  == 1)
		scenario_2  = (ab_2 == 1 and ba_2  == 1)


		return "YES" if scenario_1 or scenario_2 else "NO"



class BestSolution:
	pass


if __name__ == '__main__':
	#unittest.main()
	ans = NaiveSolution().twoSubs(input().strip())
	print(ans)
