#include <bits/stdc++.h>
int main() {
  int i, l, count = 0, marker = 0, j;
  char str[100001];
  scanf("%s", &str);
  l = strlen(str);
  for (i = 0; i <= l; i++) {
    if (str[i] == 'A' && str[i + 1] == 'B') {
      for (j = 0; j <= l; j++)
        if (str[j] == 'B' && str[j + 1] == 'A' && (i + 1) != j &&
            i != (j + 1)) {
          marker = 1;
          break;
        }
      count++;
    }
    if (marker) break;
    if (count > 2) break;
  }
  if (marker)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
