#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  size_t pos1 = s.find("AB"), pos2 = s.find("BA");
  string tmp = s;
  s.erase(0, pos1 + 2);
  tmp.erase(0, pos2 + 2);
  bool check = false;
  if (pos1 == string::npos || pos2 == string::npos) {
    cout << "NO";
  } else {
    if (s.find("BA") != string::npos || tmp.find("AB") != string::npos)
      check = true;
    if (check)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
