#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int main() {
  string s;
  cin >> s;
  int idx = s.find("AB");
  vector<int> a, b;
  while (idx >= 0) {
    a.push_back(idx);
    idx = s.find("AB", idx + 1);
  }
  idx = s.find("BA");
  while (idx >= 0) {
    b.push_back(idx);
    idx = s.find("BA", idx + 1);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a.size() == 0 || b.size() == 0) {
    cout << "NO";
    return 0;
  }
  for (auto it : a) {
    idx = upper_bound(b.begin(), b.end(), it + 1) - b.begin();
    if (idx != b.size()) {
      cout << "YES";
      return 0;
    }
  }
  for (auto it : b) {
    idx = upper_bound(a.begin(), a.end(), it + 1) - a.begin();
    if (idx != a.size()) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
