#include <bits/stdc++.h>
using namespace std;
const int N = 111;
int n;
char buf[N];
unsigned long long f[N][N][2][2][2][2];
bool v[N][N][2][2][2][2];
unsigned long long dp(int l, int r, int x, int a, int y, int b) {
  if (v[l][r][x][a][y][b]) {
    return f[l][r][x][a][y][b];
  }
  v[l][r][x][a][y][b] = true;
  unsigned long long &value = f[l][r][x][a][y][b] = 0;
  if (l == r) {
    value = (x == y) && (a ? x ^ a : y ^ b) == buf[l];
  } else if (l + 1 == r) {
    if (x == 0 && y == 1) {
      value = buf[l] == 1 && buf[r] == 0;
    } else {
      value = buf[l] == (x ^ a) && buf[r] == (y ^ b);
    }
  } else {
    for (int p = 0; p < 2; p++) {
      for (int q = 0; q < 2; q++) {
        int dir_l = x == 0 && p == 1 ? 1 : (x ^ a);
        int dir_r = q == 0 && y == 1 ? 0 : (y ^ b);
        if (dir_l == buf[l] && dir_r == buf[r]) {
          value += dp(l + 1, r - 1, p, x == 0 && p == 1, q, q == 0 && y == 1);
        }
      }
    }
  }
  return value;
}
int main() {
  scanf("%s", buf + 1);
  n = strlen(buf + 1);
  for (int i = 1; i <= n; i++) {
    buf[i] -= 'A';
  }
  unsigned long long ans = dp(1, n, 0, 0, 0, 0) + dp(1, n, 0, 0, 1, 0) +
                           dp(1, n, 1, 1, 0, 1) + dp(1, n, 1, 0, 1, 0);
  cout << ans << endl;
}
