#include <bits/stdc++.h>
using namespace std;
const int maxN = 105;
struct Bignum {
  int n, g[1005];
  Bignum() { g[n = 1] = 0; }
  Bignum(int x) { g[n = 1] = x; }
  Bignum operator+(const Bignum &o) {
    Bignum c;
    c.n = ((n) > (o.n) ? (n) : (o.n));
    int y = 0;
    for (int i = 1; i <= c.n; ++i) {
      if (i <= n) y += g[i];
      if (i <= o.n) y += o.g[i];
      c.g[i] = y % 100000000;
      y /= 100000000;
    }
    if (y) {
      c.g[++c.n] = y;
    }
    return c;
  }
} f[maxN][2], ans;
char s[maxN];
int n;
void dp() {
  for (int i = 2; i <= n; ++i) {
    if (s[i - 1] == 'A')
      f[i][0] = f[i - 1][0] + f[i - 1][1];
    else
      f[i][0] = f[i - 1][1];
    if (s[i] == 'A') {
      if (s[i - 1] == 'B')
        f[i][1] = f[i - 1][0];
      else
        f[i][1] = 0;
    } else
      f[i][1] = f[i - 1][1];
  }
}
void Work() {
  f[1][0] = 1;
  f[1][1] = 0;
  dp();
  ans = ans + f[n][1];
  if (s[n] == 'A') ans = ans + f[n][0];
  f[1][0] = 0;
  f[1][1] = 1;
  dp();
  if (s[1] == 'A' && s[n] == 'B') ans = ans + f[n][0];
  if (s[1] == 'B') ans = ans + f[n][1];
  printf("%d", ans.g[ans.n]);
  for (int i = ans.n - 1; i; --i) printf("%08d", ans.g[i]);
  puts("");
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  Work();
  return 0;
}
