#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
bool used[N];
string s;
bool check(char c, vector<int> &p1, vector<int> &p2) {
  int cnt = 0;
  char b;
  c == 'A' ? b = 'B' : b = 'A';
  for (long long i = 0; i < p1.size(); i++) {
    int u = p1[i];
    if (used[u] || used[u + 1]) continue;
    if (s[u + 1] == b) {
      cnt++;
      used[u + 1] = true;
      used[u] = true;
      break;
    }
  }
  for (long long i = 0; i < p2.size(); i++) {
    int u = p2[i];
    if (used[u] || used[u + 1]) continue;
    if (s[u + 1] == c) {
      cnt++;
      used[u + 1] = true;
      used[u] = true;
      break;
    }
  }
  return cnt == 2;
}
void solve() {
  cin >> s;
  vector<int> a, b;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'A') a.push_back(i);
    if (s[i] == 'B') b.push_back(i);
  }
  if (a.size() < 2 || b.size() < 2) {
    cout << "NO" << endl;
    return;
  }
  if (check('A', a, b)) {
    cout << "YES" << endl;
    return;
  }
  memset(used, false, sizeof(used));
  if (check('B', b, a)) {
    cout << "YES" << endl;
    return;
  }
  cout << "NO" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  solve();
  return 0;
}
