#include <bits/stdc++.h>
using namespace std;
const int mx = 1e4 + 10, inf = 1e9 + 100, mod = 1e9 + 7;
string del(string x, int i, int n) {
  int second = x.length();
  string tmp = "";
  for (int a = 0; a < second; a++) {
    if (a < i || i + n <= a)
      tmp += x[a];
    else
      tmp += '#';
  }
  return tmp;
}
int main() {
  string second, exm;
  cin >> second;
  int n = second.length();
  if (second.find("ABA") != -1) {
    exm = del(second, second.find("ABA"), 3);
    if (exm.find("BA") != -1 || exm.find("AB") != -1) goto YES;
  }
  if (second.find("BAB") != -1) {
    exm = del(second, second.find("BAB"), 3);
    if (exm.find("BA") != -1 || exm.find("AB") != -1) goto YES;
  }
  if (second.find("AB") == -1) goto NO;
  second = del(second, second.find("AB"), 2);
  if (second.find("BA") == -1) goto NO;
  goto YES;
YES : {
  cout << "YES";
  return 0;
}
NO : {
  cout << "NO";
  return 0;
}
}
