#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100001], *p;
  cin >> s;
  if (((p = strstr(s, "AB")) && (strstr(p + 2, "BA"))) ||
      ((p = strstr(s, "BA")) && (strstr(p + 2, "AB"))))
    cout << "YES\n";
  else
    cout << "NO" << endl;
  return 0;
}
