#include <bits/stdc++.h>
using namespace std;
string t = "01+-*()";
int A(string &, int &);
int B(string &, int &);
int C(string &, int &);
int C(string &s, int &idx) {
  int ret = 0;
  if (isdigit(s[idx])) {
    if (isdigit(s[idx + 1]) && s[idx] == '0') throw(0);
    while (isdigit(s[idx])) ret = ret * 2 + s[idx++] - '0';
  } else if (s[idx] == '(') {
    ret = A(s, ++idx);
    if (s[idx++] != ')') throw(0);
  } else if (s[idx] == '-')
    ret = -C(s, ++idx);
  else
    throw(0);
  return (ret);
}
int B(string &s, int &idx) {
  int ret = C(s, idx);
  while (s[idx] == '*') ret *= C(s, ++idx);
  return (ret);
}
int A(string &s, int &idx) {
  int ret = B(s, idx);
  while (s[idx] == '+' || s[idx] == '-') {
    if (s[idx] == '+')
      ret += B(s, ++idx);
    else
      ret -= B(s, ++idx);
  }
  return (ret);
}
int main() {
  string S;
  cin >> S;
  int ret = 0;
  for (int i = 1; i < S.size() - 1; i++) {
    if (isalpha(S[i]) || S[i] == '=') {
      string L = S.substr(0, i);
      string R = S.substr(i + 1);
      map<char, int> cd;
      int ptr = 0;
      for (char &c : L)
        if (isalpha(c) && !cd.count(c)) cd[c] = ptr++;
      for (char &c : R)
        if (isalpha(c) && !cd.count(c)) cd[c] = ptr++;
      vector<pair<string, string> > data;
      do {
        string x = L, y = R;
        for (char &c : x)
          if (isalpha(c)) c = t[cd[c]];
        for (char &c : y)
          if (isalpha(c)) c = t[cd[c]];
        data.emplace_back(x + "`", y + "`");
      } while (next_permutation(begin(t), end(t)));
      sort(begin(data), end(data));
      data.erase(unique(begin(data), end(data)), end(data));
      for (auto &LR : data) {
        try {
          int idx;
          int a = A(LR.first, idx = 0);
          if (idx + 1 != LR.first.size()) continue;
          int b = A(LR.second, idx = 0);
          if (idx + 1 != LR.second.size()) continue;
          ret += a == b;
        } catch (int e) {
        }
      }
    }
  }
  cout << ret << endl;
}
