#include <bits/stdc++.h>
using namespace std;
char ch[1005];
long long dp[1005][2][2];
int main() {
  scanf("%s", ch);
  int n = strlen(ch);
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  dp[0][1][1] = 1;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j <= 1; j++) {
      if (ch[i] == 'B' && ch[i + 1] == 'A') dp[i + 1][j][1] += dp[i][j][0];
      if (ch[i + 1] == 'B') dp[i + 1][j][1] += dp[i][j][1];
      if (ch[i] == 'A') dp[i + 1][j][0] += dp[i][j][0];
      dp[i + 1][j][0] += dp[i][j][1];
    }
  }
  long long sum = 0;
  sum += dp[n - 1][0][1];
  if (ch[n - 1] == 'A') sum += dp[n - 1][0][0];
  if (ch[0] == 'A' && ch[n - 1] == 'B') sum += dp[n - 1][1][0];
  if (ch[0] == 'B') sum += dp[n - 1][1][1];
  printf("%I64d\n", sum);
  return 0;
}
