#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int l, i, c = 0, d = 0, a = 0, b = 0, flag = 0, j;
  int ar[200000], ar2[200000];
  cin >> s;
  l = s.length();
  for (i = 0; i < l; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      c++;
      ar[a++] = i;
    }
  }
  for (i = 0; i < l; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      d++;
      ar2[b++] = i;
    }
  }
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      if ((abs(ar[i] - ar2[j])) >= 2) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
