#include <bits/stdc++.h>
using namespace std;
char ch[210];
int N;
int top, st[110];
long long dp[2][60][2];
bool ju[60];
int main() {
  int i, j, k;
  memset(ju, true, sizeof(ju));
  scanf("%s", ch);
  N = strlen(ch);
  for (i = 0; i < N; i++) ch[N + i] = ch[i];
  int a, b, s;
  top = 0;
  for (i = 0; i < N; i++) {
    if (ch[i] == 'B' && ch[i + 1] == 'A') {
      st[top++] = i;
    }
  }
  if (top == 0) {
    printf("1\n");
  } else {
    st[top] = st[0] + N;
    bool jud = true;
    for (k = 0; k < top; k++) {
      a = st[k];
      b = st[k + 1];
      if (ch[a + 2] != 'B' && ch[b - 1] != 'A') jud = false;
      if (a + 2 < b) {
        if (ch[a + 2] == 'B') ju[k + 1] = false;
        if (ch[b - 1] == 'A') ju[k + 2] = false;
      }
    }
    if (!jud)
      printf("0\n");
    else {
      dp[0][1][0] = dp[1][1][1] = 1;
      if (!ju[1] || !ju[top + 1]) dp[0][1][0] = 0;
      for (k = 0; k < 2; k++) {
        for (i = 2; i <= top; i++) {
          if (ju[i]) dp[k][i][0] = dp[k][i - 1][1];
          dp[k][i][1] = dp[k][i - 1][0] + dp[k][i - 1][1];
        }
      }
      printf("%I64d\n", dp[0][top][1] + dp[1][top][0] + dp[1][top][1]);
    }
  }
  return 0;
}
