#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  int n = s.size(), i = 0;
  int ab = s.find("AB");
  int ba = s.rfind("BA");
  int ab1 = s.rfind("AB");
  int ba1 = s.find("BA");
  if (ab == -1 || ba == -1)
    cout << "NO\n";
  else if ((ab + 1 == ba || ba + 1 == ab) && (ab1 + 1 == ba1 || ba1 + 1 == ab1))
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
