#include <bits/stdc++.h>
using namespace std;
long long m, j, k, i, x, y, c1, c2, n, dp[1000005];
int main() {
  char p[100004];
  long long i, j, k, l, m = 0;
  cin >> p;
  i = 0;
  l = 0, m = 0;
  while (i < strlen(p) - 1) {
    if (p[i] == 'A' && p[i + 1] == 'B' && l < 1) {
      i += 2;
      l++;
    }
    if (p[i] == 'B' && p[i + 1] == 'A' && m < 1 && l > 0) {
      i += 2;
      m++;
    }
    i++;
    if (l >= 1 && m >= 1) break;
  }
  long long l1, m1;
  i = 0, l1 = 0, m1 = 0;
  while (i < strlen(p) - 1) {
    if (p[i] == 'B' && p[i + 1] == 'A' && m1 < 1) {
      i += 2;
      m1++;
    }
    if (p[i] == 'A' && p[i + 1] == 'B' && l1 < 1 && m1 > 0) {
      i += 2;
      l1++;
    }
    i++;
    if (l1 >= 1 && m1 >= 1) break;
  }
  if (l + m >= 2 || l1 + m1 >= 2)
    cout << "YES";
  else
    cout << "NO";
}
