#include <bits/stdc++.h>
using namespace std;
int ans;
string s;
long long exp(string::const_iterator &begin);
long long bin(string::const_iterator &begin) {
  long long ret = 0;
  while (isdigit(*begin)) {
    ret *= 2;
    ret += *begin - '0';
    begin++;
  }
  return ret;
}
long long number(string::const_iterator &begin) {
  if (*begin == '0') {
    begin++;
    if (isdigit(*begin))
      throw "number error1";
    else
      return 0;
  } else if (*begin == '1') {
    return bin(begin);
  } else
    throw "number error2";
  assert(1);
  return -1;
}
long long factor(string::const_iterator &begin) {
  if (isdigit(*begin))
    return number(begin);
  else if (*begin == '-') {
    int minus = 0;
    while (*begin == '-') {
      minus++;
      begin++;
    }
    if (isdigit(*begin))
      return -(minus % 2) * number(begin);
    else if (*begin == '(')
      return -(minus % 2) * exp(begin);
    else
      throw "factor error1";
  } else if (*begin == '(') {
    begin++;
    long long ret = exp(begin);
    if (*begin != ')') throw "factor error2";
    begin++;
    return ret;
  } else
    throw "factor error3";
  assert(1);
  return -1;
}
long long term(string::const_iterator &begin) {
  long long ret = factor(begin);
  if (*begin == '+' || *begin == '-' || *begin == '$' || *begin == ')') {
    return ret;
  } else if (*begin == '*') {
    begin++;
    return ret * term(begin);
  } else
    throw "term error";
  assert(1);
  return -1;
}
long long exp(string::const_iterator &begin) {
  long long ret = term(begin);
  if (*begin == '+') {
    begin++;
    return ret + exp(begin);
  } else if (*begin == '-') {
    begin++;
    return ret - exp(begin);
  } else if (*begin == '$' || *begin == ')') {
    return ret;
  } else
    throw "exp error";
  assert(1);
  return -1;
}
bool isValid(string tmp) {
  int eqc = 0;
  for (long long i = 0; i < (long long)(tmp.size()); i++)
    if (tmp[i] == '=') eqc++;
  if (eqc != 1) return false;
  string str[2] = {};
  bool f = false;
  for (long long i = 0; i < (long long)(tmp.size()); i++) {
    if (tmp[i] == '=')
      f = true;
    else if (f)
      str[1] += tmp[i];
    else
      str[0] += tmp[i];
  }
  if (str[0].size() == 0 || str[1].size() == 0) return false;
  string::const_iterator b[2];
  long long res[2];
  try {
    for (long long i = 0; i < (long long)(2); i++) {
      str[i] += '$';
      b[i] = str[i].begin();
      res[i] = exp(b[i]);
    }
  } catch (char const *e) {
    return false;
  }
  if (res[0] == res[1] && *b[0] == '$' && *b[1] == '$') {
    return true;
  } else
    return false;
}
void dfs(string tmp, vector<bool> used) {
  char alp = '!';
  int pos = -1;
  for (long long i = 0; i < (long long)(tmp.size()); i++) {
    if (isalpha(tmp[i])) alp = tmp[i], pos = i;
  }
  if (pos == -1) {
    if (isValid(tmp)) ans++;
    return;
  }
  assert(alp != '!');
  string symbols = "01+-*()=";
  for (long long i = 0; i < (long long)(symbols.size()); i++) {
    if (used[i]) continue;
    used[i] = true;
    string ntmp = tmp;
    for (long long j = 0; j < (long long)(ntmp.size()); j++) {
      if (ntmp[j] == alp) ntmp[j] = symbols[i];
    }
    dfs(ntmp, used);
    used[i] = false;
  }
}
int main() {
  cin >> s;
  set<char> st;
  vector<char> vs;
  for (long long i = 0; i < (long long)(s.size()); i++) st.insert(s[i]);
  int c = 0;
  for (auto &e : st) vs.push_back(e);
  if (vs.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  ans = 0;
  vector<bool> used(8, false);
  dfs(s, used);
  cout << ans << endl;
}
