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