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).
The only line of input contains a string *s* of length between 1 and 10<sup class="upper-index">5</sup> consisting of uppercase Latin letters.
from heapq import heapify,heappop,heappush
from queue import deque
from collections import defaultdict
import math

def I(): return int(input())
def ST(): return input()
def IL(): return list(map(int, input().split()))
def ILS(): return sorted(map(int, input().split()))
def STL(): return list(input())

def solve():
    word = ST()
    AB,BA = word.count("AB"),word.count("BA")
    print(AB,BA)
    if AB == 1 and BA == 1:
        if "ABA" not in word and "BAB" not in word:
            print("YES")
            return

    print("NO")
       
T = 1
# T = I()
for _ in range(T):
    solve()