#include <bits/stdc++.h>
using namespace std;
long long N, M, K, R, A, B, X, Y, Z, C, D, a, b, c, d, i, j, k, first;
void solve() {
  string S;
  cin >> S;
  N = S.length();
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  for (long long int i = 0; i < N - 1; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B' && a == 0) {
      a = 1;
      i++;
    } else if (S[i] == 'B' && S[i + 1] == 'A' && b == 0) {
      b = 1;
      i++;
    }
  }
  for (long long i = N - 1; i > 0; i--) {
    if (S[i] == 'A' && S[i - 1] == 'B' && c == 0) {
      c = 1;
      i--;
    } else if (S[i] == 'B' && S[i - 1] == 'A' && d == 0) {
      d = 1;
      i--;
    }
  }
  if (a + b == 2 || c + d == 2)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
