#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> meetA, meetB;
  for (int i = 0; i + 1 < S.size(); ++i) {
    if (S[i] == 'A' && S[i + 1] == 'B') {
      meetA.push_back(i);
    }
    if (S[i] == 'B' && S[i + 1] == 'A') {
      meetB.push_back(i);
    }
  }
  if (!meetA.size() || !meetB.size()) {
    cout << "NO";
    return 0;
  }
  int p1 = *meetA.begin();
  int p2 = meetB.back();
  if (abs(p1 - p2) > 1) {
    cout << "YES";
    return 0;
  }
  p1 = meetA.back();
  p2 = *meetB.begin();
  if (abs(p2 - p1) > 1) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
