#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char str[100005];
  scanf("%s", str);
  bool flag = 0;
  long int x;
  for (long int i = 0; i < strlen(str) - 1; i++) {
    if (str[i] == 'A' && str[i + 1] == 'B') {
      flag = 1;
      x = i;
      break;
    }
  }
  bool f = 0;
  if (flag)
    for (long int i = 0; i < strlen(str) - 1; i++) {
      if (i != x && i != (x + 1) && i != (x - 1))
        if (str[i] == 'B' && str[i + 1] == 'A') {
          f = 1;
          printf("YES");
          return 0;
          break;
        }
    }
  flag = 0;
  for (long int i = 0; i < strlen(str) - 1; i++) {
    if (str[i] == 'B' && str[i + 1] == 'A') {
      flag = 1;
      x = i;
      break;
    }
  }
  f = 0;
  if (flag)
    for (long int i = 0; i < strlen(str) - 1; i++) {
      if (i != x && i != (x + 1) && i != (x - 1))
        if (str[i] == 'A' && str[i + 1] == 'B') {
          f = 1;
          printf("YES");
          return 0;
          break;
        }
    }
  printf("NO");
  return 0;
}
