#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int p1 = s.find("AB", 0);
  int p2 = s.find("BA", 0);
  int p3 = s.find("AB", p2 + 2);
  int p4 = s.find("BA", p1 + 2);
  if ((p1 >= 0 && p4 >= 0) || (p2 >= 0 && p3 >= 0))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
