#include <bits/stdc++.h>
using namespace std;
string temp = "01+-*()=";
long long A(string&, long long&);
long long B(string&, long long&);
long long C(string&, long long&);
long long C(string& S, long long& idx) {
  long long 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);
    ++idx;
  } else if (S[idx] == '-') {
    ret = -C(S, ++idx);
  } else {
    throw(0);
  }
  return (ret);
}
long long B(string& S, long long& idx) {
  long long ret = C(S, idx);
  while (S[idx] == '*') {
    ret *= B(S, ++idx);
  }
  return (ret);
}
long long A(string& S, long long& idx) {
  long long ret = B(S, idx);
  while (S[idx] == '+' || S[idx] == '-') {
    if (S[idx] == '+')
      ret += A(S, ++idx);
    else
      ret -= A(S, ++idx);
  }
  return (ret);
}
signed main() {
  string S;
  long long conv[32];
  memset(conv, -1, sizeof(conv));
  cin >> S;
  vector<char> num;
  for (char& c : S) {
    if (isalpha(c)) num.push_back(c);
  }
  sort(begin(num), end(num));
  num.erase(unique(begin(num), end(num)), end(num));
  for (long long i = 0; i < S.size(); i++) {
    if (isalpha(S[i]))
      conv[i] = lower_bound(begin(num), end(num), S[i]) - begin(num);
  }
  if (num.size() > temp.size()) {
    cout << 0 << endl;
    return (0);
  }
  sort(begin(temp), end(temp));
  vector<string> ss;
  do {
    string T = S;
    for (long long i = 0; i < S.size(); i++) {
      if (~conv[i]) T[i] = temp[conv[i]];
    }
    if (count(begin(T), end(T), '=') == 1 && T.front() != '=' &&
        T.back() != '=') {
      ss.push_back(T);
    }
  } while (next_permutation(begin(temp), end(temp)));
  sort(begin(ss), end(ss));
  ss.erase(unique(begin(ss), end(ss)), end(ss));
  long long ret = 0;
  for (string& al : ss) {
    string L = "", R = "";
    bool which = false;
    for (long long i = 0; i < al.size(); i++) {
      if (al[i] == '=') {
        which = true;
        continue;
      }
      (which ? R : L) += al[i];
    }
    R += "$";
    L += "$";
    long long idx;
    try {
      long long ll = A(L, idx = 0);
      if (idx + 1 != L.size()) continue;
      long long rr = A(R, idx = 0);
      if (idx + 1 != R.size()) continue;
      ret += ll == rr;
    } catch (long long e) {
    }
  }
  cout << ret << endl;
}
