#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  bool f1 = true;
  int x3 = 0, x4 = 0;
  int x1, x2;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      x1 = i + 2;
      x3 = 1;
      f1 = false;
      break;
    }
  }
  bool f2 = true;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      x2 = i + 2;
      x4 = 1;
      f2 = false;
      break;
    }
  }
  if (!f1) {
    for (int i = x1; i < s.size() - 1; i++) {
      if (s[i] == 'B' && s[i + 1] == 'A') {
        f1 = true;
        x3++;
        break;
      }
    }
  }
  if (!f2) {
    for (int i = x2; i < s.size() - 1; i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') {
        f2 = true;
        x4++;
        break;
      }
    }
  }
  if (x3 == 2 || x4 == 2)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
