#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ct1 = 0, ct2 = 0, ct3 = 0;
  for (int i = 0; i < s.length(); i++) {
    if ((s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'A') ||
        (s[i] == 'B' && s[i + 1] == 'A' && s[i + 2] == 'B') && ct3 == 0) {
      ct3++;
      i += 2;
    } else if (s[i] == 'A' && s[i + 1] == 'B') {
      ct1++;
      if (s[i + 2] == 'A') i += 2;
    } else if (s[i] == 'B' && s[i + 1] == 'A') {
      ct2++;
      if (s[i + 2] == 'B') {
        i += 2;
      }
    }
  }
  if ((ct1 && ct2) || (ct3 && ct1) || (ct3 && ct2)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
