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