#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len, flag = 0;
  len = s.size();
  for (int i = 0; i < len - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      for (int j = i + 2; j < len - 1; j++) {
        if (s[j] == 'B' && s[j + 1] == 'A') {
          flag = 1;
          break;
        }
      }
    } else if (s[i] == 'B' && s[i + 1] == 'A') {
      for (int j = i + 2; j < len - 1; j++) {
        if (s[j] == 'A' && s[j + 1] == 'B') {
          flag = 1;
          break;
        }
      }
    }
  }
  if (flag == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
