#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  char temp[500000];
  scanf("%s", &temp);
  s = temp;
  int ABFound = -1;
  int BAFound = -1;
  bool YES = false;
  for (int i = 0; i < s.size() - 1 && !YES; i++) {
    if (s[i] == 'A')
      if (s[i + 1] == 'B') {
        if (ABFound == -1) ABFound = i;
        if (BAFound != -1) {
          int Distancia = i > BAFound ? i - BAFound : BAFound - i;
          if (Distancia >= 2) YES = true;
        }
      }
    if (s[i] == 'B')
      if (s[i + 1] == 'A') {
        if (BAFound == -1) BAFound = i;
        if (ABFound != -1) {
          int Distancia = ABFound > i ? ABFound - i : i - ABFound;
          if (Distancia >= 2) YES = true;
        }
      }
  }
  YES ? printf("YES") : printf("NO");
  return 0;
}
