#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  std::vector<int> va;
  std::vector<int> vb;
  std::vector<int> vaa;
  std::vector<int> vbb;
  for (int i = 0; i < s.length(); i++) {
    if (i + 1 < s.length() && s[i] == 'A' && s[i + 1] == 'B') {
      va.push_back(i + 1);
      vaa.push_back(i);
    } else if (i + 1 < s.length() && s[i] == 'B' && s[i + 1] == 'A') {
      vb.push_back(i);
      vbb.push_back(i + 1);
    }
  }
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  for (int i = 0; i < va.size(); i++) {
    int ind = lower_bound(vb.begin(), vb.end(), va[i] + 1) - vb.begin();
    if (ind < vb.size() && vb[ind] > va[i]) {
      cout << "YES";
      return;
    }
  }
  sort(vaa.begin(), vaa.end());
  sort(vbb.begin(), vbb.end());
  for (int i = 0; i < vbb.size(); i++) {
    int ind = lower_bound(vaa.begin(), vaa.end(), vbb[i] + 1) - vaa.begin();
    if (ind < vaa.size() && vaa[ind] > vbb[i]) {
      cout << "YES";
      return;
    }
  }
  cout << "NO";
}
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
