#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long n = str.length();
  bool flag1 = false, flag2 = false, flag3 = false, flag4 = false;
  for (long i = 0; i < n - 1; i++) {
    if ((flag1 && flag2) || (flag3 && flag4)) break;
    if (str[i] == 'A' && str[i + 1] == 'B') {
      flag1 = true;
      for (long j = i + 2; j < n - 1; j++) {
        if (str[j] == 'B' && str[j + 1] == 'A') {
          flag2 = true;
        }
      }
    }
    if (str[i] == 'B' && str[i + 1] == 'A') {
      flag3 = true;
      for (long j = i + 2; j < n; j++) {
        if (str[j] == 'A' && str[j + 1] == 'B') {
          flag4 = true;
        }
      }
    }
  }
  if ((flag1 && flag2) || (flag3 && flag4))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
