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>
using namespace std;
const long long INF = 9e15;
long long mod = 1000000007;
long long gcd(long long a, long long b) {
  if (b > a) {
    return gcd(b, a);
  }
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long expo(long long a, long long b, long long mod) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b = b >> 1;
  }
  return res;
}
long long invprime(long long a, long long b) { return expo(a, b - 2, b); }
long long addmod(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long mulmod(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
long long submod(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long divmod(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (mulmod(a, invprime(b, m), m) + m) % m;
}
vector<int> sieve(int n) {
  int* arr = new int[n + 1]();
  vector<int> vect;
  for (int i = 2; i <= n; i++)
    if (arr[i] == 0) {
      vect.push_back(i);
      for (int j = 2 * i; j <= n; j += i) arr[j] = 1;
    }
  return vect;
}
void google(int x) { cout << "Case #" << x << ": "; }
template <typename T>
void sort(vector<T>& v) {
  std::sort(v.begin(), v.end());
  return;
}
template <typename T>
void sortbig(vector<T>& v) {
  std::sort(v.begin(), v.end(), greater<T>());
  return;
}
template <typename T>
T max(vector<T>& v) {
  return *(max_element(v.begin(), v.end()));
}
template <typename T>
T min(vector<T>& v) {
  return *(min_element(v.begin(), v.end()));
}
template <typename T>
ostream& operator<<(ostream& stream, vector<T>& v) {
  for (T& x : v) stream << x << " ";
  return stream;
}
template <typename T>
istream& operator>>(istream& stream, vector<T>& v) {
  for (T& x : v) stream >> x;
  return stream;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t t1, t2;
  t1 = clock();
  int tc = 0, tt = 1;
  while (tc++ < tt) {
    string s;
    cin >> s;
    int n = s.length();
    unordered_set<int> ab, ba;
    for (int i = 0; i < n - 1; i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') {
        for (int j = i + 2; j < n - 1; j++) {
          if (s[j] == 'B' && s[j + 1] == 'A') {
            cout << "YES" << '\n';
            return 0;
          }
        }
        break;
      }
    }
    for (int i = 0; i < n - 1; i++) {
      if (s[i] == 'B' && s[i + 1] == 'A') {
        for (int j = i + 2; j < n - 1; j++) {
          if (s[j] == 'A' && s[j + 1] == 'B') {
            cout << "YES" << '\n';
            return 0;
          }
        }
        break;
      }
    }
    cout << "NO" << '\n';
  }
  return 0;
}
