#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> posA, posB;
int main(int argc, const char* argv[]) {
  cin >> s;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') posA.push_back(i);
    if (s[i] == 'B' && s[i + 1] == 'A') posB.push_back(i);
  }
  for (int i = 0; i < posA.size(); i++)
    for (int j = 0; j < posB.size(); j++) {
      if (abs(posA[i] - posB[j]) > 1) {
        cout << "YES";
        return 0;
      }
    }
  cout << "NO";
  return 0;
}
