#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  int flagF = 0, flagS = 0;
  string s;
  cin >> s;
  int n = s.size(), i;
  for (i = 1; i < n; i++) {
    if (s[i] == 'B' && s[i - 1] == 'A') {
      flagF++;
      break;
    }
  }
  for (i += 2; i < n; i++) {
    if (s[i] == 'A' && s[i - 1] == 'B') {
      flagS++;
      break;
    }
  }
  if (flagF + flagS > 1) {
    cout << "YES";
    return 0;
  }
  flagF = 0;
  flagS = 0;
  for (i = 1; i < n; i++) {
    if (s[i] == 'A' && s[i - 1] == 'B') {
      flagF++;
      break;
    }
  }
  for (i += 2; i < n; i++) {
    if (s[i] == 'B' && s[i - 1] == 'A') {
      flagS++;
      break;
    }
  }
  cout << (flagF + flagS > 1 ? "YES" : "NO");
  return 0;
}
