#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
char a[N];
long long f[N][3][3];
bool v[3][3];
int main() {
  scanf("%s", a + 1), n = strlen(a + 1);
  if (a[1] == 'A') {
    f[1][0][0] = 1;
    f[1][1][1] = 1;
    f[1][2][2] = 0;
  } else {
    f[1][0][0] = 0;
    f[1][1][1] = 1;
    f[1][2][2] = 1;
  }
  for (int s = 0; s <= 2; ++s)
    for (int i = 2; i <= n; ++i) {
      if (a[i] == 'A') {
        if (a[i - 1] == 'A') {
          f[i][0][s] = 0;
          f[i][1][s] = f[i - 1][0][s] + f[i - 1][1][s];
          f[i][2][s] = 0;
        } else {
          f[i][0][s] = f[i - 1][2][s];
          f[i][1][s] = f[i - 1][1][s];
          f[i][2][s] = 0;
        }
      } else {
        if (a[i - 1] == 'A') {
          f[i][0][s] = 0;
          f[i][1][s] = f[i - 1][0][s];
          f[i][2][s] = f[i - 1][0][s] + f[i - 1][1][s];
        } else {
          f[i][0][s] = 0;
          f[i][1][s] = f[i - 1][1][s];
          f[i][2][s] = f[i - 1][1][s];
        }
      }
    }
  if (a[n] == 'A') {
    if (a[1] == 'A') {
      v[0][1] = 1;
      v[1][1] = 1;
    } else {
      v[0][1] = 1;
      v[0][2] = 1;
      v[1][2] = 1;
    }
  } else {
    if (a[1] == 'A') {
      v[1][1] = 1;
      v[2][0] = 1;
    } else {
      v[1][1] = 1;
      v[1][2] = 1;
    }
  }
  long long ans = 0;
  for (int s = 0; s <= 2; ++s)
    for (int i = 0; i <= 2; ++i)
      if (v[i][s]) ans += f[n][i][s];
  cout << ans << endl;
  return 0;
}
