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".
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int INF = 1e9;
const int N = 1e6;
using namespace std;
int Exp(int x, int y) {
  int ans = 1;
  for (int i = 1; i <= y; i++) ans *= x;
  return ans;
}
vector<bool> check_prime(N + 1, true);
void Seive() {
  check_prime[0] = false;
  check_prime[1] = false;
  for (long long i = 2; i * i <= N; i++) {
    if (check_prime[i]) {
      for (long long j = i * i; j <= N; j += i) check_prime[j] = false;
    }
  }
}
bool prime(int x) {
  bool ok = true;
  if (x < 2) return false;
  if (x == 2)
    return true;
  else {
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        return false;
      }
    }
    return true;
  }
}
int dp[1000000];
int h[1000000];
int det(int x1, int y1, int x2, int y2, int x3, int y3) {
  int val = abs(x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y1);
  return val;
}
void solve(int tc) {
  string s;
  cin >> s;
  vector<pair<int, int>> AB;
  vector<pair<int, int>> BA;
  if (s.size() >= 2) {
    for (int i = 0; i <= s.size() - 2; i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') AB.push_back({i, i + 1});
    }
    for (int i = 0; i <= s.size() - 2; i++) {
      if (s[i] == 'B' && s[i + 1] == 'A') BA.push_back({i, i + 1});
    }
    if (AB.size() > 0 && BA.size() > 0) {
      bool ok = false;
      for (auto x : AB) {
        for (auto y : BA) {
          if (x.first != y.first && x.second != y.second &&
              x.first != y.second && x.second != y.first) {
            ok = true;
            break;
          }
        }
        if (ok) break;
      }
      cout << (ok ? "YES" : "NO");
    } else
      cout << "NO";
  } else
    cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
}
