#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
long long res;
long long dp[N][2];
char mde[N];
int n;
inline void dypr() {
  for (int i = 1; i <= n; i++) {
    dp[i + 1][0] = (mde[i] == 'A') ? dp[i][0] + dp[i][1] : dp[i][1];
    if (mde[i + 1] == 'A') {
      if (mde[i] == 'B') dp[i + 1][1] = dp[i][0];
    } else {
      dp[i + 1][1] = dp[i][1];
    }
  }
}
int main() {
  scanf("%s", mde + 1);
  for (n = 1; mde[n + 1] != '\0'; n++)
    ;
  mde[n + 1] = mde[1];
  dp[1][0] = 1;
  dypr();
  res += dp[n + 1][0];
  for (int i = 1; i <= n + 1; i++) dp[i][0] = dp[i][1] = 0;
  dp[1][1] = 1;
  dypr();
  res += dp[n + 1][1];
  printf("%I64d", res);
}
