#include <bits/stdc++.h>
using namespace std;
class ATwoSubstrings {
 public:
  void solve(std::istream& in, std::ostream& out) {
    string S;
    in >> S;
    unordered_set<int> a, b;
    for (int i = 0; i < (S.size() - 1); ++i) {
      if (S[i] == 'A' and S[i + 1] == 'B') a.emplace(i);
      if (S[i] == 'B' and S[i + 1] == 'A') b.emplace(i);
    }
    if (a.empty() or b.empty()) {
      out << "NO" << '\n';
      return;
    } else if (a.size() < 2 or b.size() < 2) {
      for (auto u : a) {
        for (auto v : b) {
          if (u + 1 < v or v + 1 < u) {
            out << "YES" << '\n';
            return;
          }
        }
      }
      out << "NO" << '\n';
      return;
    } else {
      out << "YES" << '\n';
      return;
    }
  }
};
int main() {
  ATwoSubstrings solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
