#include <bits/stdc++.h>
using namespace std;
void solve() {}
int main() {
  string str;
  cin >> str;
  int a, b, c, d;
  a = str.find("AB");
  b = str.find("BA", a + 2);
  c = str.find("BA");
  d = str.find("AB", c + 2);
  if ((a != -1 && b != -1) || (c != -1 && d != -1))
    puts("YES");
  else
    puts("NO");
}
