#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int n;
string s;
long long dp[105][3][3];
long long dfs(int i, char p, char st) {
  if (i == n - 1)
    return dp[i][p - 'A'][st - 'A'] =
               (!(p == 'A' && s[i] == 'B') &&
                (n != s.size() || !(s[i] == 'A' && st == 'B')));
  if (i == n)
    return dp[i][p - 'A'][st - 'A'] =
               (n != s.size() || !(p == 'A' && st == 'B'));
  if (dp[i][p - 'A'][st - 'A'] != -1) return dp[i][p - 'A'][st - 'A'];
  if (p == 'A' && s[i] == 'B') {
    if (s[i + 1] == 'A') return dp[i][p - 'A'][st - 'A'] = dfs(i + 2, 'B', st);
    return dp[i][p - 'A'][st - 'A'] = 0;
  }
  int nst = st;
  if (i == 0) nst = s[0];
  long long ret = dfs(i + 1, s[i], nst);
  if (s[i] == 'B' && s[i + 1] == 'A') {
    if (i == 0) nst = 'A';
    ret += dfs(i + 2, 'B', nst);
  }
  return dp[i][p - 'A'][st - 'A'] = ret;
}
int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  cin >> s;
  n = s.size();
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  ans += dfs(0, 'C', 'C');
  if (s[0] == 'A' && s[n - 1] == 'B') {
    swap(s[0], s[n - 1]);
    memset(dp, -1, sizeof(dp));
    --n;
    ans += dfs(1, s[0], s[0]);
  }
  cout << ans << '\n';
  return 0;
}
