#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  if ((s.find("AB") != -1 && s.find("BA", s.find("AB") + 2) != -1) ||
      (s.find("BA") != -1 && s.find("AB", s.find("BA") + 2) != -1))
    cout << "YES";
  else
    cout << "NO";
}
