#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b != 0 ? a : gcd(b, a % b); }
long long power(long long a, long long b, long long mod) {
  long long c = 1;
  while (b > 0) {
    if (b % 2) c *= a, c %= mod;
    b /= 2;
    a *= a;
    a %= mod;
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin.tie(0);
  long long t, n;
  string s, s1;
  cin >> s;
  n = 0;
  t = 0;
  s1 = s;
  for (long long i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      s[i] = 'Z';
      s[i + 1] = 'Z';
      n = 1;
      break;
    }
  }
  for (long long i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      s[i] = 'Z';
      s[i + 1] = 'Z';
      t = 1;
      break;
    }
  }
  if (t && n)
    cout << "YES";
  else {
    t = 0;
    n = 0;
    for (long long i = 0; i < s1.length() - 1; i++) {
      if (s1[i] == 'B' && s1[i + 1] == 'A') {
        s1[i] = 'Z';
        s1[i + 1] = 'Z';
        t = 1;
        break;
      }
    }
    for (long long i = 0; i < s1.length() - 1; i++) {
      if (s1[i] == 'A' && s1[i + 1] == 'B') {
        s[i] = 'Z';
        s[i + 1] = 'Z';
        n = 1;
        break;
      }
    }
    if (t && n)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
