#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, i, j;
  string s;
  cin >> s;
  if (s.size() < 4) {
    cout << "NO"
         << "\n";
    return;
  }
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      for (j = i + 2; j < s.size(); j++) {
        if (s[j] == 'B' && s[j + 1] == 'A') {
          cout << "YES"
               << "\n";
          return;
        }
      }
      break;
    }
  }
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      for (j = i + 2; j < s.size(); j++) {
        if (s[j] == 'A' && s[j + 1] == 'B') {
          cout << "YES"
               << "\n";
          return;
        }
      }
      break;
    }
  }
  cout << "NO"
       << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
