#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int a = 0, b = 0, f = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'A' && s[i] == 'B' && f == 0) {
      f = 1;
      i += 1;
    } else if (s[i - 1] == 'B' && s[i] == 'A' && f == 1) {
      b = 1;
      break;
    }
  }
  f = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'B' && s[i] == 'A' && f == 0) {
      f = 1;
      i += 1;
    } else if (s[i - 1] == 'A' && s[i] == 'B' && f == 1) {
      a = 1;
      break;
    }
  }
  if (a || b)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
