#include <bits/stdc++.h>
using namespace std;
vector<string> docs;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  bool ab = false;
  bool ba = false;
  string s;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'A') {
      s = str.substr(i, 3);
      if (i < str.size() - 2 && s == "ABA") {
        docs.push_back(s);
        i += 2;
        continue;
      }
      s = str.substr(i, 2);
      if (i != str.size() - 1 && s == "AB") {
        docs.push_back(s);
        i++;
        continue;
      }
    } else if (str[i] == 'B') {
      s = str.substr(i, 3);
      if (i < str.size() - 2 && s == "BAB") {
        docs.push_back(s);
        i += 2;
        continue;
      }
      s = str.substr(i, 2);
      if (i != s.size() - 1 && s == "BA") {
        docs.push_back(s);
        i++;
        continue;
      }
    }
  }
  if (docs.empty()) {
    cout << "NO" << endl;
    return 0;
  }
  s = docs[0];
  for (int i = 1; i < docs.size(); i++) {
    if (s == "ABA") {
      if (docs[i] == "ABA" || docs[i] == "BA" || docs[i] == "AB" ||
          docs[i] == "BAB") {
        ab = true;
        break;
      }
    }
    if (s == "AB") {
      if (docs[i] == "ABA" || docs[i] == "BA" || docs[i] == "BAB") {
        ab = true;
        break;
      }
    }
    if (s == "BA") {
      if (docs[i] == "ABA" || docs[i] == "AB" || docs[i] == "BAB") {
        ab = true;
        break;
      }
    }
    if (s == "BAB") {
      if (docs[i] == "ABA" || docs[i] == "BA" || docs[i] == "AB" ||
          docs[i] == "BAB") {
        ab = true;
        break;
      }
    }
  }
  if (ab) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
