#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void print_array(int A[], int N) {
  for (int i = 0; i < N; i++) cout << A[i] << ' ';
  cout << endl;
}
long long mx(long long arr[], int N) {
  long long pp = 0;
  for (int i = 0; i < N; i++) pp = max(pp, arr[i]);
  return pp;
}
void solve() {
  string S;
  cin >> S;
  int N = S.length();
  set<int> first, second;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B') first.insert(i);
    if (S[i] == 'B' && S[i + 1] == 'A') second.insert(i);
  }
  if (min(first.size(), second.size()) > 1)
    cout << "YES" << endl;
  else {
    if (min(first.size(), second.size()) == 0)
      cout << "NO" << endl;
    else {
      if (max(first.size(), second.size()) > 2)
        cout << "YES" << endl;
      else if (max(first.size(), second.size()) == 2) {
        if (abs(*first.begin() - *second.begin()) == 1) {
          if (first.size() == 2) {
            if (abs(*(++first.begin()) - *second.begin()) == 1)
              cout << "NO" << endl;
            else
              cout << "YES" << endl;
          } else {
            if (abs(*(++second.begin()) - *first.begin()) == 1)
              cout << "NO" << endl;
            else
              cout << "YES" << endl;
          }
        } else
          cout << "YES" << endl;
      } else {
        if (abs(*first.begin() - *second.begin()) == 1)
          cout << "NO" << endl;
        else
          cout << "YES" << endl;
      }
    }
  }
}
int main() {
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
