#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int x, long long int y) {
  return y == 0 ? x : gcd(y, x % y);
}
bool isPalin(string x) {
  long long int len = x.length();
  for (int i = 0; i <= (len / 2) - 1; ++i) {
    if (x[i] != x[len - 1 - i]) return false;
  }
  return true;
}
string tolowerStr(string x) {
  string ret = "";
  for (int i = 0; i <= (long long int)x.length() - 1; ++i) {
    ret.push_back(tolower(x[i]));
  }
  return ret;
}
string toupperStr(string x) {
  string ret = "";
  for (int i = 0; i <= (long long int)x.length() - 1; ++i) {
    ret.push_back(toupper(x[i]));
  }
  return ret;
}
long long int modulo(long long int a, long long int b, long long int c) {
  long long int res = 1;
  for (int i = 0; i < b; i++) {
    res *= a;
    res %= c;
  }
  return res % c;
}
bool double_equals(double a, double b, double epsilon = 0.1) {
  return std::abs(a - b) < epsilon;
}
int mark1[100005];
int mark2[100005];
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  int len, f1 = 0, f2 = 0;
  cin >> s;
  len = s.length();
  for (int i = 0; i <= len - 2; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'B') {
      mark1[i] = 1;
    }
    if (s[i] == 'B' && s[i + 1] == 'A') {
      mark2[i] = 1;
      ;
    }
  }
  for (int i = 0; i <= len - 1; ++i) {
    if (mark1[i] == 1) {
      for (int j = i + 2; j <= len - 1; ++j) {
        if (mark2[j] == 1) {
          f1 = 1;
          break;
        }
      }
      for (int j = 0; j <= i - 2; ++j) {
        if (mark2[j] == 1) {
          f1 = 1;
          break;
        }
      }
    }
  }
  if (f1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
