#include <bits/stdc++.h>
using namespace std;
int INT_MAX_VAL = (int)0x3F3F3F3F;
int INT_MIN_VAL = (int)-0x3F3F3F3F;
long long LONG_MAX_VAL = (long long)0x3F3F3F3F3F3F3F3F;
long long LONG_MIN_VAL = (long long)-0x3F3F3F3F3F3F3F3F;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int i1 = s.find("AB"), i2 = s.rfind("AB");
  int j1 = s.find("BA"), j2 = s.rfind("BA");
  if ((abs(i1 - j2) > 1 || abs(i2 - j1) > 1) && i1 != -1 && j1 != -1) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}
