#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
const long long INF = 1001001001001001001ll;
string S;
long long ei(string::iterator &it, long long r) {
  if (r == 0) {
    vector<long long> lis;
    while (it != S.end()) {
      long long x = ei(it, 1);
      if (*it != '=' || x == INF) return INF;
      lis.push_back(x);
      it++;
    }
    if (lis.size() != 2 || lis[0] != lis[1]) return INF;
    return 114514;
  }
  if (r == 1) {
    long long ret = ei(it, 2);
    if (ret == INF) return INF;
    while (true) {
      if (*it == '+') {
        it++;
        long long x = ei(it, 2);
        if (x == INF) return INF;
        ret += x;
      } else if (*it == '-') {
        it++;
        long long x = ei(it, 2);
        if (x == INF) return INF;
        ret -= x;
      } else
        break;
    }
    return ret;
  }
  if (r == 2) {
    long long ret = ei(it, 3);
    if (ret == INF) return INF;
    while (true) {
      if (*it == '*') {
        it++;
        long long x = ei(it, 3);
        if (x == INF) return INF;
        ret *= x;
      } else
        break;
    }
    return ret;
  }
  if (r == 3) {
    if (*it == '-') {
      it++;
      long long x = ei(it, 3);
      if (x == INF) return INF;
      return -x;
    }
    if (*it == '(') {
      it++;
      long long x = ei(it, 1);
      if (*it != ')') return INF;
      it++;
      if (x == INF) return INF;
      return x;
    }
    return ei(it, 4);
  }
  if (r == 4) {
    bool f = *it == '0';
    long long ret = 0;
    while (isdigit(*it)) {
      ret = ret * 2 + *it - '0';
      it++;
    }
    if (!f && ret == 0) return INF;
    if (f && ret != 0) return INF;
    return ret;
  }
}
signed main() {
  string s;
  cin >> s;
  vector<char> v;
  for (long long i = 0; i < (s.size()); i++)
    if (isalpha(s[i])) v.push_back(s[i]);
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
  if (v.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  string x = "+-*()=01";
  sort((x).begin(), (x).end());
  long long ans = 0;
  set<string> st;
  do {
    S = s;
    for (long long i = 0; i < (S.size()); i++) {
      if (isalpha(S[i])) {
        long long k = lower_bound((v).begin(), (v).end(), S[i]) - v.begin();
        S[i] = x[k];
      }
    }
    S += "=";
    auto it = S.begin();
    if (ei(it, 0) != INF) {
      ans++;
    }
  } while (next_permutation((x).begin(), (x).end()));
  for (long long i = 0; i < ((long long)x.size() - (long long)v.size()); i++)
    ans /= i + 1;
  cout << ans << endl;
  return 0;
}
