#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  if (str.length() < 4) {
    cout << "NO" << endl;
  } else {
    int AB = 0, BA = 0, ABpos = 0, BApos = 0;
    for (int i = 0; i + 1 < str.length(); i++) {
      if (str[i] == 'A' && str[i + 1] == 'B') {
        AB++;
        ABpos = i;
      }
      if (str[i] == 'B' && str[i + 1] == 'A') {
        BA++;
        BApos = i;
      }
    }
    if (AB > 1 && BA > 1) {
      cout << "YES" << endl;
    } else if (AB == 1 || BA == 1) {
      if (AB == 0 || BA == 0) {
        cout << "NO" << endl;
      } else if (abs(ABpos - BApos) != 1) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
