#include <bits/stdc++.h>
using namespace std;
long i, cnt, pos1[long(1e6 + 100)], j;
string s;
int main() {
  cin >> s;
  for (i = 0; i < s.length() - 1; i++)
    if (s[i] == 'A' && s[i + 1] == 'B') pos1[++cnt] = i;
  for (i = 0; i < s.length() - 1; i++)
    if (s[i] == 'B' && s[i + 1] == 'A') {
      for (j = 1; j <= cnt; j++)
        if (pos1[j] != i - 1 && pos1[j] != i + 1) {
          printf("YES");
          return 0;
        }
    }
  printf("NO");
  return 0;
}
