#include <bits/stdc++.h>
using namespace std;
bool arr[100001];
int main() {
  string s;
  cin >> s;
  int n = s.length();
  memset(arr, false, sizeof(arr));
  int i;
  for (i = 0; i < n - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      arr[i] = true;
      arr[i + 1] = true;
      break;
    }
  }
  if (i == n - 1) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A' && !arr[i] && !arr[i + 1]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  memset(arr, false, sizeof(arr));
  for (i = 0; i < n - 1; i++) {
    if (s[i] == 'B' && s[i + 1] == 'A') {
      arr[i] = true;
      arr[i + 1] = true;
      break;
    }
  }
  if (i == n - 1) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && !arr[i] && !arr[i + 1]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
