#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  string AB = "AB";
  string BA = "BA";
  if (a.find(AB) == string::npos or a.find(BA) == string::npos) {
    cout << "NO";
    return 0;
  }
  int posAB = a.find(AB);
  if (a.find(BA, posAB + 2) != string::npos) {
    cout << "YES";
    return 0;
  }
  int posBA = a.find(BA);
  if (a.find(AB, posBA + 2) != string::npos) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
