#include <bits/stdc++.h>
using namespace std;
long long f[100][2][2];
int main() {
  string s;
  cin >> s;
  int n = s.length();
  if (s[0] == 'A') s = s.substr(1) + 'A';
  memset(f, 0, sizeof(f));
  if (s[0] == 'A')
    f[0][0][0] += 1;
  else
    f[0][1][1] += 1;
  if (s[0] == 'B' && s[1] == 'A') f[1][0][1] += 1;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < 2; j++) {
      if (i > 1 && s[i - 1] == 'B' && s[i] == 'A') {
        f[i][j][1] += f[i - 2][j][0] + f[i - 2][j][1];
      }
      if (s[i] == 'A') f[i][j][0] += f[i - 1][j][0] + f[i - 1][j][1];
      if (s[i] == 'B') f[i][j][1] += f[i - 1][j][1];
    }
  cout << f[n - 1][0][0] + f[n - 1][0][1] + f[n - 1][1][1] << endl;
  return 0;
}
