#include <bits/stdc++.h>
using namespace std;
int main() {
  string st;
  cin >> st;
  int len = st.length();
  int ABstart = 0;
  int BAstart = 0;
  int flg = 0;
  for (int i = 0; i < len - 1; i++) {
    if (flg == 1) break;
    if (st[i] == 'A' && st[i + 1] == 'B') {
      ABstart = i;
      for (int j = 0; j < len - 1; j++) {
        if (st[j] == 'B' && st[j + 1] == 'A') {
          BAstart = j;
          if (i - j == 1 || i - j == -1)
            continue;
          else {
            flg = 1;
            break;
          }
        }
      }
    }
  }
  if (flg == 1)
    cout << "YES";
  else
    cout << "NO";
}
