#include <bits/stdc++.h>
using namespace std;
string in;
int N;
string on;
vector<char> SET;
vector<char> TO;
long long dp[110][2];
long long calc(int pos, int w) {
  if (dp[pos][w] != -1) return dp[pos][w];
  dp[pos][w] = 0;
  if (SET[pos] && TO[pos] != w) return 0;
  if (w == 0) {
    if (on[pos] == 0)
      dp[pos][w] += ((pos - 1 >= 0) ? calc(pos - 1, 0) + calc(pos - 1, 1) : 1);
  } else {
    if (on[pos] == 1) dp[pos][w] += ((pos - 1 >= 0) ? calc(pos - 1, 1) : 1);
    if (pos > 0 && on[pos] == 0 && on[pos - 1] == 1 &&
        (!SET[pos - 1] || TO[pos - 1] == 0))
      dp[pos][w] += (pos - 2 >= 0 ? calc(pos - 2, 0) + calc(pos - 2, 1) : 1);
  }
  return dp[pos][w];
}
long long doit() {
  memset(dp, -1, sizeof dp);
  return calc(((int)(on).size()) - 1, 0) + calc(((int)(on).size()) - 1, 1);
}
int main() {
  cin >> in;
  N = ((int)(in).size());
  for (int i = 0; i < N; ++i) in[i] -= 'A';
  long long ans = 0;
  for (int lo = 0; lo < 2; ++lo)
    for (int hi = 0; hi < 2; ++hi) {
      if (hi == 0 && lo == 1) {
        if (in[0] == 0 && in[N - 1] == 1) {
          on = in.substr(1, N - 2);
          SET = vector<char>(N - 2, 0);
          ans += doit();
        }
      } else {
        on = in;
        SET = vector<char>(N, 0);
        SET[0] = SET[N - 1] = 1;
        TO = vector<char>(N, 0);
        TO[0] = lo;
        TO[N - 1] = hi;
        ans += doit();
      }
    }
  cout << ans << '\n';
  return 0;
}
