#include <bits/stdc++.h>
using namespace std;
string s;
long long f[105][2], len, ans;
int main() {
  cin >> s;
  len = s.size();
  s = " " + s;
  s[len + 1] = s[1];
  f[1][0] = 1;
  for (int i = 1; i <= len; i++) {
    if (s[i] == 'A')
      f[i + 1][0] = f[i][0] + f[i][1];
    else
      f[i + 1][0] = f[i][1];
    if (s[i + 1] == 'A') {
      if (s[i] == 'B') f[i + 1][1] = f[i][0];
    } else
      f[i + 1][1] = f[i][1];
  }
  ans += f[len + 1][0];
  memset(f, 0, sizeof(f));
  f[1][1] = 1;
  for (int i = 1; i <= len; i++) {
    if (s[i] == 'A')
      f[i + 1][0] = f[i][0] + f[i][1];
    else
      f[i + 1][0] = f[i][1];
    if (s[i + 1] == 'A') {
      if (s[i] == 'B') f[i + 1][1] = f[i][0];
    } else
      f[i + 1][1] = f[i][1];
  }
  ans += f[len + 1][1];
  cout << ans;
  return 0;
}
