#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
long long f[N][2];
char S[N];
int n;
int main() {
  cin >> S;
  n = strlen(S);
  S[n] = S[0];
  long long res(0);
  for (int firstv = 0; firstv < 2; ++firstv) {
    f[0][firstv] = 1;
    f[0][!firstv] = 0;
    for (int i = 1; i <= n; ++i)
      for (int a = 0; a < 2; ++a) {
        f[i][a] = 0;
        for (int b = 0; b < 2; ++b) {
          if (a == 1 && b == 0 && !(S[i - 1] == 'B' && S[i] == 'A')) continue;
          if (a == 0 && b == 0 && S[i - 1] != 'A') continue;
          if (a == 1 && b == 1 && S[i] != 'B') continue;
          f[i][a] += f[i - 1][b];
        }
      }
    res += f[n][firstv];
  }
  cout << res << endl;
}
