#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int *ab, *ba, len, numa = 0, numb = 0;
  bool check = false;
  len = s.length();
  ab = new int[len];
  ba = new int[len];
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      ab[numa++] = i;
    }
    if (s[i] == 'A' && s[i + 1] == 'B') {
      ba[numb++] = i;
    }
    if (numa > 0 && numb > 0 && abs(ab[numa - 1] - ba[numb - 1]) > 1 ||
        (numa >= 2 && numb >= 2)) {
      check = true;
      break;
    }
  }
  if (check)
    cout << "YES";
  else
    cout << "NO";
  delete[] ab;
  delete[] ba;
  return 0;
}
