#include <bits/stdc++.h>
const int maxn = 110;
int n, a[maxn];
long long dp[maxn][2], ans;
char s[maxn];
int main() {
  scanf("%s", s);
  n = strlen(s);
  s[n] = s[0];
  for (int start = 0; start < 2; start++) {
    memset(dp, 0, sizeof(dp));
    dp[0][start] = 1;
    for (int i = 1; i <= n; i++) {
      if (s[i] == 'B')
        dp[i][1] += dp[i - 1][1];
      else if (s[i - 1] == 'B')
        dp[i][1] += dp[i - 1][0];
      if (s[i - 1] == 'A') dp[i][0] += dp[i - 1][0];
      dp[i][0] += dp[i - 1][1];
    }
    ans += dp[n][start];
  }
  printf("%I64d\n", ans);
  return 0;
}
