#include <bits/stdc++.h>
using namespace std;
int find(string s, string sub, int begin, int end) {
  for (int i = begin; i < end - 1; i++)
    if (s[i] == sub[0] && s[i + 1] == sub[1]) return i;
  return -1;
}
int main() {
  string s, sub;
  cin >> s;
  int size = s.size();
  int index1, index2, index3, index4;
  index1 = find(s, "AB", 0, size);
  index2 = find(s, "BA", 0, size);
  index3 = find(s, "BA", index1 + 2, size);
  index4 = find(s, "AB", index2 + 2, size);
  if ((index1 + 1 && index3 + 1) || (index2 + 1 && index4 + 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
