#include <bits/stdc++.h>
using namespace std;
long long d[110][3];
char s[110];
int main() {
  int i, k, n;
  long long r;
  for (scanf("%s", s), n = 0; s[n]; n++)
    ;
  r = 0;
  s[n] = s[0];
  for (k = 0; k < 3; k++) {
    d[0][0] = 0;
    d[0][1] = 0;
    d[0][2] = 0;
    d[0][k] = 1;
    for (i = 1; i <= n; i++) {
      if (s[i - 1] == 'A' && s[i] == 'A') {
        d[i][0] = d[i - 1][0] + d[i - 1][1];
        d[i][1] = 0;
        d[i][2] = 0;
      }
      if (s[i - 1] == 'A' && s[i] == 'B') {
        d[i][0] = d[i - 1][1];
        d[i][1] = 0;
        d[i][2] = d[i - 1][0] + d[i - 1][1];
      }
      if (s[i - 1] == 'B' && s[i] == 'A') {
        d[i][0] = d[i - 1][0];
        d[i][1] = d[i - 1][2];
        d[i][2] = 0;
      }
      if (s[i - 1] == 'B' && s[i] == 'B') {
        d[i][0] = d[i - 1][0];
        d[i][1] = 0;
        d[i][2] = d[i - 1][0];
      }
    }
    r += d[n][k];
  }
  printf("%I64d\n", r);
  return 0;
}
