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