#include <bits/stdc++.h>
using namespace std;
char s[110];
long long dp[110][2];
void solve(int x, int y) {
  memset(dp, 0, sizeof(dp));
  dp[x][y] = 1;
  int len = strlen(s);
  for (int i = 1; i < len; i++) {
    if (dp[i - 1][0] != 0) {
      if (s[i] == 'A') dp[i][1] += dp[i - 1][0];
      if (s[i] == 'B') dp[i][0] += dp[i - 1][0];
      if (s[i] == 'B' && s[i + 1] == 'A') dp[i + 1][0] += dp[i - 1][0];
    }
    if (dp[i - 1][1] != 0) {
      if (s[i] == 'A') dp[i][1] += dp[i - 1][1];
      if (s[i] == 'B' && s[i + 1] == 'A') dp[i + 1][0] += dp[i - 1][1];
    }
  }
}
int main() {
  scanf("%s", s);
  int len = strlen(s);
  long long ans = 0;
  if (s[0] == 'A') {
    solve(0, 1);
    ans += dp[len - 1][0] + dp[len - 1][1];
    if (s[len - 1] == 'B') {
      solve(0, 0);
      ans += dp[len - 2][0] + dp[len - 2][1];
    }
  } else {
    solve(0, 0);
    ans += dp[len - 1][0];
    if (s[1] == 'A') {
      solve(1, 0);
      ans += dp[len - 1][0] + dp[len - 1][1];
    }
  }
  cout << ans << endl;
  return 0;
}
