#include <bits/stdc++.h>
using namespace std;
string str;
int mlo1 = -1, mro1 = -1, mlo2 = -1, mro2 = -1;
bool found1, found2;
ifstream fin("in.txt");
int main() {
  cin >> str;
  for (int i = 0; i < (str.size() - 1); i++) {
    if (str[i] == 'A' and str[i + 1] == 'B') {
      if (!found1) {
        mlo1 = i;
        found1 = 1;
      }
      mro1 = i;
    }
    if (str[i] == 'B' and str[i + 1] == 'A') {
      if (!found2) {
        mlo2 = i;
        found2 = 1;
      }
      mro2 = i;
    }
  }
  if (mlo2 != -1 and mlo1 != -1 and
      ((mlo1 < mro2 and mlo1 + 1 != mro2) or
       (mlo2 < mro1 and mlo2 + 1 != mro1))) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
