#include <bits/stdc++.h>
using namespace std;
const long long LLINF = LLONG_MAX;
const bool debug = false;
const string opr = "01+-*=()";
string context;
int n;
long long parse_E(int &, string &);
long long parse_F(int &p, string &s) {
  if (p >= (int)s.size()) return LLINF;
  if (s[p] == '+') return LLINF;
  if (s[p] == '-') {
    ++p;
    long long v = parse_F(p, s);
    if (v == LLINF) return LLINF;
    return v * -1LL;
  }
  if (s[p] == '(') {
    ++p;
    long long v = parse_E(p, s);
    if (v == LLINF) return LLINF;
    if (p >= (int)s.size()) return LLINF;
    if (s[p] != ')') return LLINF;
    ++p;
    return v;
  }
  int cnt = 0;
  long long v = 0;
  bool first_zero = (s[p] == '0');
  while (p < (int)s.size() && (s[p] == '0' || s[p] == '1')) {
    v <<= 1;
    v += (long long)(s[p] - '0');
    ++p;
    ++cnt;
  }
  if (first_zero && cnt != 1) return LLINF;
  if (cnt == 0) return LLINF;
  if (p < (int)s.size() && s[p] == '(') return LLINF;
  return v;
}
long long parse_T(int &p, string &s) {
  long long v = parse_F(p, s);
  if (v == LLINF) return v;
  while (p < (int)s.size() && s[p] == '*') {
    ++p;
    long long tmp = parse_T(p, s);
    if (tmp == LLINF) return tmp;
    v *= tmp;
  }
  return v;
}
long long parse_E(int &p, string &s) {
  long long v = parse_T(p, s);
  if (v == LLINF) return v;
  while (p < (int)s.size() && (s[p] == '+' || s[p] == '-')) {
    char op = s[p];
    ++p;
    long long tmp = parse_T(p, s);
    if (tmp == LLINF) return tmp;
    if (op == '+') v += tmp;
    if (op == '-') v -= tmp;
  }
  return v;
}
bool pari_check(string &s) {
  int cnt = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == '(') ++cnt;
    if (s[i] == ')') --cnt;
    if (cnt < 0) return false;
  }
  return cnt == 0;
}
bool check() {
  string s, t;
  {
    string tmp;
    tmp = context;
    for (int i = 0; i < n; ++i)
      if (context[i] == '=') tmp[i] = ' ';
    vector<string> vec;
    stringstream ss;
    ss << tmp;
    while (ss >> s) vec.push_back(s);
    if (vec.size() != 2) return false;
    s = vec[0];
    t = vec[1];
  }
  if (!pari_check(s) || !pari_check(t)) return false;
  int p = 0;
  long long sv = parse_E(p, s);
  p = 0;
  long long tv = parse_E(p, t);
  if (sv == LLINF || tv == LLINF) return false;
  return sv == tv;
}
int dfs(int ptr, int used, vector<char> &already) {
  if (n <= ptr) {
    if (debug) {
      if (check()) {
        cout << "succeeded : " << context << endl;
        return true;
      } else {
        return false;
      }
    } else {
      return check();
    }
  }
  if (!isalpha(context[ptr])) return dfs(ptr + 1, used, already);
  int sum = 0;
  int v = context[ptr] - 'a';
  if (already[v] != '$') {
    if (already[v] == '=') return 0;
    char tmp = context[ptr];
    context[ptr] = already[v];
    sum += dfs(ptr + 1, used, already);
    context[ptr] = tmp;
    return sum;
  }
  for (int i = 0; i < (int)opr.size(); ++i) {
    if ((used >> i) & 1) continue;
    char tmp = context[ptr];
    context[ptr] = opr[i];
    already[v] = opr[i];
    sum += dfs(ptr + 1, used | (1 << i), already);
    already[v] = '$';
    context[ptr] = tmp;
  }
  return sum;
}
bool normalize() {
  vector<char> vec;
  for (int i = 0; i < (int)context.size(); ++i)
    if (isalpha(context[i])) vec.push_back(context[i]);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < (int)context.size(); ++i)
    if (isalpha(context[i])) {
      int pos = lower_bound(vec.begin(), vec.end(), context[i]) - vec.begin();
      context[i] = (char)('a' + pos);
    }
  return (int)vec.size() <= 8;
}
void compute() {
  if (debug) cout << "      context : " << context << endl;
  if (!normalize()) {
    puts("0");
    return;
  }
  if (debug) cout << "fixed context : " << context << endl;
  n = (int)context.size();
  int used = 0;
  for (int i = 0; i < n; ++i)
    if (context[i] == '=') {
      used = (1 << 5);
      break;
    }
  vector<char> vec(8, '$');
  cout << dfs(0, used, vec) << endl;
}
int main() {
  if (0) {
    string s;
    cin >> s;
    int p = 0;
    cout << parse_E(p, s) << endl;
    return 0;
  }
  cin >> context;
  compute();
  return 0;
}
