#include <bits/stdc++.h>
using namespace std;
char s[1005], t[1005];
long long dp[1005][2], a[1005];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int mark = -1;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'B') {
      mark = i;
      break;
    }
  }
  if (mark == -1) {
    printf("1\n");
    return 0;
  }
  for (int i = 0; i < len; i++) {
    t[i + 1] = s[(i + mark) % len];
  }
  long long ans1 = 0, ans2 = 0;
  dp[0][0] = 1;
  for (int i = 0; i < len; i++) {
    if (t[i + 1] == 'B') {
      dp[i + 1][0] = dp[i][0];
    } else {
      if (t[i] == 'A') {
        dp[i + 1][1] = dp[i][0] + dp[i][1];
      } else {
        dp[i + 1][0] = dp[i - 1][0] + dp[i - 1][1];
        dp[i + 1][1] = dp[i][0] + dp[i][1];
      }
    }
  }
  ans1 = dp[len][0];
  memset(dp, 0, sizeof(dp));
  dp[0][1] = 1;
  for (int i = 0; i < len; i++) {
    if (t[i + 1] == 'B') {
      dp[i + 1][0] = dp[i][0];
    } else {
      if (t[i] == 'A') {
        dp[i + 1][1] = dp[i][0] + dp[i][1];
      } else {
        dp[i + 1][0] = dp[i - 1][0] + dp[i - 1][1];
        dp[i + 1][1] = dp[i][0] + dp[i][1];
      }
    }
  }
  ans2 = dp[len][1];
  printf("%lld\n", ans1 + ans2);
  return 0;
}
