#include <bits/stdc++.h>
using namespace std;
const long long N = 105;
char s[N];
long long dp[N][2][2], n, ans;
signed main() {
  scanf("%s", s + 1);
  long long n = strlen(s + 1);
  dp[1][0][s[1] == 'B'] = 1;
  s[n + 1] = s[1];
  for (long long i = 2; i <= n + 1; i++) {
    if (s[i - 1] == 'A' && s[i] == 'A') {
      dp[i][0][0] += dp[i - 1][0][0];
      dp[i][0][0] += dp[i - 1][1][1];
    } else if (s[i - 1] == 'A' && s[i] == 'B') {
      dp[i][0][1] += dp[i - 1][0][0] + dp[i - 1][1][1];
      dp[i][1][0] += dp[i - 1][1][1];
    } else if (s[i - 1] == 'B' && s[i] == 'B') {
      dp[i][1][0] += dp[i - 1][1][0];
      dp[i][0][1] += dp[i - 1][1][0];
    } else if (s[i - 1] == 'B' && s[i] == 'A') {
      dp[i][0][0] += dp[i - 1][1][0];
      dp[i][1][1] += dp[i - 1][0][1];
    }
  }
  ans += dp[n + 1][0][s[1] == 'B'];
  memset(dp, 0, sizeof(dp));
  dp[1][1][s[1] == 'A'] = 1;
  s[n + 1] = s[1];
  for (long long i = 2; i <= n + 1; i++) {
    if (s[i - 1] == 'A' && s[i] == 'A') {
      dp[i][0][0] += dp[i - 1][0][0];
      dp[i][0][0] += dp[i - 1][1][1];
    } else if (s[i - 1] == 'A' && s[i] == 'B') {
      dp[i][0][1] += dp[i - 1][0][0] + dp[i - 1][1][1];
      dp[i][1][0] += dp[i - 1][1][1];
    } else if (s[i - 1] == 'B' && s[i] == 'B') {
      dp[i][1][0] += dp[i - 1][1][0];
      dp[i][0][1] += dp[i - 1][1][0];
    } else if (s[i - 1] == 'B' && s[i] == 'A') {
      dp[i][0][0] += dp[i - 1][1][0];
      dp[i][1][1] += dp[i - 1][0][1];
    }
  }
  ans += dp[n + 1][1][s[1] == 'A'];
  printf("%lld\n", ans);
}
