#include <bits/stdc++.h>
using namespace std;
long long f[110][2], ans;
char a[110];
int main() {
  scanf("%s", a);
  if (a[0] == 'A') {
    memset(f, 0, sizeof(f));
    f[0][a[0] - 'A'] = 1;
    for (int i = 1; i < strlen(a); i++) {
      if (a[i] == 'A') {
        f[i][0] = f[i - 1][0] + f[i - 1][1];
        if (a[i - 1] == 'B' && i > 1) f[i][1] = f[i - 2][0] + f[i - 2][1];
      } else {
        f[i][1] = f[i - 1][1];
      }
    }
    if (a[0] == 'A')
      ans += f[strlen(a) - 1][0] + f[strlen(a) - 1][1];
    else
      ans += f[strlen(a) - 1][1];
    if (a[strlen(a) - 1] == 'B') {
      swap(a[0], a[strlen(a) - 1]);
      memset(f, 0, sizeof(f));
      f[0][a[0] - 'A'] = 1;
      for (int i = 1; i < strlen(a); i++) {
        if (a[i] == 'A') {
          f[i][0] = f[i - 1][0] + f[i - 1][1];
          if (a[i - 1] == 'B' && i > 1 && i < strlen(a) - 1)
            f[i][1] = f[i - 2][0] + f[i - 2][1];
        } else {
          f[i][1] = f[i - 1][1];
        }
      }
      ans += f[strlen(a) - 1][0];
    }
  } else {
    memset(f, 0, sizeof(f));
    f[0][a[0] - 'A'] = 1;
    for (int i = 1; i < strlen(a); i++) {
      if (a[i] == 'A') {
        f[i][0] = f[i - 1][0] + f[i - 1][1];
        if (a[i - 1] == 'B' && i > 1) f[i][1] = f[i - 2][0] + f[i - 2][1];
      } else {
        f[i][1] = f[i - 1][1];
      }
    }
    if (a[0] == 'A')
      ans += f[strlen(a) - 1][0] + f[strlen(a) - 1][1];
    else
      ans += f[strlen(a) - 1][1];
    if (a[1] == 'A') {
      swap(a[1], a[0]);
      memset(f, 0, sizeof(f));
      f[0][a[0] - 'A'] = 1;
      f[1][a[1] - 'A'] = 1;
      for (int i = 2; i < strlen(a); i++) {
        if (a[i] == 'A') {
          f[i][0] = f[i - 1][0] + f[i - 1][1];
          if (a[i - 1] == 'B' && i > 2) f[i][1] = f[i - 2][0] + f[i - 2][1];
        } else {
          f[i][1] = f[i - 1][1];
        }
      }
      if (a[0] == 'A')
        ans += f[strlen(a) - 1][0] + f[strlen(a) - 1][1];
      else
        ans += f[strlen(a) - 1][1];
    }
  }
  printf("%lld", ans);
}
