#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  bool ok = false;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      for (int j = i + 2; j < n - 1; j++) {
        if (s[j] == 'B' && s[j + 1] == 'A') {
          ok = true;
          break;
        }
      }
    }
    if (ok) break;
  }
  if (ok) {
    cout << "YES\n";
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      for (int j = i + 2; j < n - 1; j++) {
        if (s[j] == 'A' && s[j + 1] == 'B') {
          ok = true;
          break;
        }
      }
    }
    if (ok) break;
  }
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
}
