You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).

Input

The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.

Output

Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.

Examples

Input

ABA


Output

NO


Input

BACFAB


Output

YES


Input

AXBYBXA


Output

NO

Note

In the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".

In the second sample test there are the following occurrences of the substrings: BACFAB.

In the third sample test there is no substring "AB" nor substring "BA".
#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;
}
