#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll M = 1000000007;
const ll M1 = 998244353;
using vl = vector<ll>;
using pll = pair<ll, ll>;
ll power(ll x, ll y) {
  if (y == 0) return 1;
  ll res = power(x, y / 2);
  res = (res * res);
  if (y & 1) res = (res * x);
  return res;
}
ll powermod(ll x, ll y, ll mod) {
  if (y == 0) return 1;
  ll res = powermod(x, y / 2, mod);
  res = (res * res) % mod;
  if (y & 1) res = (res * x) % mod;
  return res;
}
void solve() {
  string s;
  cin >> s;
  int cnt = 0, cnt1 = 0;
  int f = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      for (int j = i + 2; j < s.size() - 1; j++) {
        if (s[j] == 'A' && s[j + 1] == 'B') f = 1;
      }
      break;
    }
  }
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      for (int j = i + 2; j < s.size() - 1; j++) {
        if (s[j] == 'B' && s[j + 1] == 'A') f = 1;
      }
      break;
    }
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
