#include <bits/stdc++.h>
using namespace std;
int64_t dp[305][3];
char s[305];
int32_t main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  cin >> s;
  int64_t n = strlen(s);
  s[n] = s[0];
  dp[0][0] = 1;
  for (int64_t i = 1; i <= n; i++) {
    if (s[i - 1] == 'A') {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    } else
      dp[i][0] = dp[i - 1][1];
    if (s[i] == 'A' && s[i - 1] == 'B')
      dp[i][1] = dp[i - 1][0];
    else if (s[i] == 'B')
      dp[i][1] = dp[i - 1][1];
  }
  int64_t ans = 0;
  ans += dp[n][0];
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int64_t i = 1; i <= n; i++) {
    if (s[i - 1] == 'A') {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    } else
      dp[i][0] = dp[i - 1][1];
    if (s[i] == 'A' && s[i - 1] == 'B')
      dp[i][1] = dp[i - 1][0];
    else if (s[i] == 'B')
      dp[i][1] = dp[i - 1][1];
  }
  cout << ans + dp[n][1] << '\n';
  return 0;
}
