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