#include <bits/stdc++.h>
using namespace std;
char s[(int)1e5 + 5];
int main() {
  while (cin >> s) {
    char *c;
    if ((c = strstr(s, "AB")) != NULL && (strstr(c + 2, "BA") != NULL))
      cout << "YES" << endl;
    else if ((c = strstr(s, "BA")) != NULL && (strstr(c + 2, "AB") != NULL))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
