#include <bits/stdc++.h>
using namespace std;
int N;
string s;
long long dp[100 + 5][2][2];
long long doDP(int idx, int firstStat, int curStat) {
  if (idx == N) {
    return firstStat == curStat;
  }
  long long &ret = dp[idx][firstStat][curStat];
  if (ret != -1) return ret;
  ret = 0;
  if (s[idx] == 'B') {
    if (curStat && s[idx + 1] == 'A') {
      ret = doDP(idx + 2, firstStat, curStat) +
            doDP(idx + 2, firstStat, !curStat);
      ;
    } else if (curStat) {
      ret = 0;
    } else
      ret = doDP(idx + 1, firstStat, curStat) +
            doDP(idx + 1, firstStat, !curStat);
  } else {
    if (curStat) {
      ret = 0;
    } else if (idx + 1 == N || s[idx + 1] == 'B')
      ret = doDP(idx + 1, firstStat, 1);
    else
      ret = doDP(idx + 1, firstStat, 0);
  }
  return ret;
}
long long solve() {
  bool flag = true;
  int Bidx = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] != s[0]) {
      flag = false;
    }
    if (Bidx == 0 && s[i] == 'B' && i > 0 && s[i - 1] == 'A') Bidx = i;
  }
  if (flag) return 1;
  rotate(s.begin(), s.begin() + Bidx, s.end());
  memset(dp, -1, sizeof(dp));
  long long ret1 = doDP(0, 0, 0);
  long long ret2 = doDP(0, 1, 1);
  return ret1 + ret2;
}
int main() {
  cin >> s;
  N = (s).size();
  cout << solve() << endl;
  return 0;
}
