#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  if (s.length() <= 3)
    cout << "NO" << endl;
  else {
    int c = 0, d = 0;
    s += 'S';
    s += 'S';
    for (int i = (0); i < (s.length() - 2); i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') {
        if (s[i + 2] == 'A') {
          i += 2;
        } else {
          c++;
          i++;
        }
      } else if (s[i] == 'B' && s[i + 1] == 'A') {
        if (s[i + 2] == 'B') {
          i += 2;
        } else {
          d++;
          i++;
        }
      }
    }
    int k = 0;
    for (int i = (0); i < (s.length() - 2); i++) {
      if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'A') {
        k++;
        i += 2;
      } else if (s[i] == 'B' && s[i + 1] == 'A' && s[i + 2] == 'B') {
        k++;
        i += 2;
      }
    }
    while (k--) {
      if (c == 0)
        c++;
      else
        d++;
    }
    if (c > 0 && d > 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
