#include <bits/stdc++.h>
using namespace std;
string s;
bool ok(char A, char B) {
  int siz = -1;
  for (int i = 0; i < s.length() - 1; i++)
    if (s[i] == A && s[i + 1] == B) {
      siz = i;
      break;
    }
  if (siz == -1) return false;
  for (int i = siz + 2; i < s.length() - 1; i++)
    if (s[i] == B && s[i + 1] == A) {
      return true;
    }
  return false;
}
int main() {
  while (cin >> s) {
    (ok('A', 'B') || ok('B', 'A')) ? puts("YES") : puts("NO");
  }
  return 0;
}
