#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int a, b, c, d;
  string s;
  cin >> s;
  a = s.find("AB");
  b = s.find("BA", a + 2);
  c = s.find("BA");
  d = s.find("AB", c + 2);
  if ((a >= 0 && b >= 0) || (c >= 0 && d >= 0))
    cout << "YES";
  else
    cout << "NO";
  cout << "\n";
  ;
  return 0;
}
