#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  int a, b, c, i, j, k, m, n, sum;
  double r, x, y, z;
  string str;
  getline(cin, str);
  char prev = str[0];
  int min_ab = 1000000;
  int min_ba = 1000000;
  int max_ab = -1;
  int max_ba = -1;
  for (i = 1; i < str.size(); ++i) {
    if ((str[i] == 'A') || (str[i] == 'B')) {
      if (prev == 'A') {
        if (str[i] == 'B') {
          if (max_ab < i) {
            max_ab = i;
          }
          if (min_ab > i) {
            min_ab = i;
          }
        }
      } else if (prev == 'B') {
        if (str[i] == 'A') {
          if (max_ba < i) {
            max_ba = i;
          }
          if (min_ba > i) {
            min_ba = i;
          }
        }
      }
    }
    prev = str[i];
  }
  if ((max_ba - min_ab > 1) || (max_ab - min_ba > 1)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
