#include <bits/stdc++.h>
using namespace std;
const int MAX = 100 + 10;
int n;
char str[MAX];
long long f[MAX][2];
long long work(int l, int r) {
  memset(f, 0, sizeof f);
  int i;
  f[l - 1][0] = 1, f[l - 1][1] = 0;
  for (i = l - 1; i < r; ++i) {
    if (f[i][0]) {
      if (str[i + 1] == 'B') {
        if (str[i + 2] == 'A' && i + 2 <= r) f[i + 2][0] += f[i][0];
        f[i + 1][0] += f[i][0];
      } else
        f[i + 1][1] += f[i][0];
    }
    if (f[i][1]) {
      if (str[i + 1] == 'B' && str[i + 2] == 'A' && i + 2 <= r)
        f[i + 2][0] += f[i][1];
      else if (str[i + 1] == 'A')
        f[i + 1][1] += f[i][1];
    }
  }
  return f[r][0] + f[r][1];
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  long long ans = 0;
  if (str[n] == 'A' && str[1] == 'B') {
    if (str[2] == 'A') ans += work(3, n);
    if (str[n - 1] == 'B') ans += work(1, n - 2);
    if (str[2] == 'A' && str[n - 1] == 'B') ans -= work(3, n - 2);
  } else {
    ans += work(1, n);
    if (str[1] == 'A' && str[n] == 'B') ans += work(2, n - 1);
  }
  cout << ans << endl;
  return 0;
}
