#include <bits/stdc++.h>
using namespace std;
int modular_pow(long long int base, long long int exponent, int m) {
  if (exponent == 0)
    return 1;
  else if (exponent % 2 == 0) {
    long long int res = modular_pow(base, exponent / 2, m);
    return (res * res + m) % m;
  } else {
    return (modular_pow(base, exponent - 1, m) * base) % m;
  }
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool chek(int x) { return (x && !(x & (x - 1))); }
int onebits(int n) { return __builtin_popcount(n); }
string s;
int main() {
  cin >> s;
  if (s.length() <= 3)
    puts("NO");
  else {
    string s1;
    bool fl = true;
    int in;
    for (int u = 0; u < s.length() - 1; u += 1) {
      if (s[u] == 'A' && s[u + 1] == 'B') {
        s1 = "BA";
        fl = false;
        in = u + 2;
        break;
      }
    }
    if (fl)
      puts("NO");
    else {
      bool fl2 = true;
      for (int u = in; u < s.length() - 1; u++) {
        if (s[u] == s1[0] && s[u + 1] == s1[1]) {
          puts("YES");
          fl2 = false;
          break;
        }
      }
      if (fl2) {
        string s11;
        bool fl1 = true;
        int in1;
        for (int u = 0; u < s.length() - 1; u += 1) {
          if (s[u] == 'B' && s[u + 1] == 'A') {
            s11 = "AB";
            fl1 = false;
            in1 = u + 2;
            break;
          }
        }
        if (fl1)
          puts("NO");
        else {
          bool fl3 = true;
          for (int u = in1; u < s.length() - 1; u++) {
            if (s[u] == s11[0] && s[u + 1] == s11[1]) {
              puts("YES");
              fl3 = false;
              break;
            }
          }
          if (fl3) puts("NO");
        }
      }
    }
  }
  return 0;
}
