#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  bool ab = false, ba = false;
  cin >> s;
  int l = s.length();
  for (int i = 1; i < l; i++) {
    if (s[i - 1] == 'A' && s[i] == 'B' && ab == false) {
      ab = true;
      i++;
      continue;
    }
    if (s[i - 1] == 'B' && s[i] == 'A' && ab == true) {
      ba = true;
      break;
    }
  }
  if (ab && ba) {
    cout << "YES";
    return 0;
  } else {
    ab = false;
    ba = false;
  }
  for (int i = 1; i < l; i++) {
    if (s[i - 1] == 'B' && s[i] == 'A' && ba == false) {
      ba = true;
      i++;
      continue;
    }
    if (s[i - 1] == 'A' && s[i] == 'B' && ba == true) {
      ab = true;
      break;
    }
  }
  cout << (ab && ba ? "YES" : "NO");
  return 0;
}
