#include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(a) (a).begin(),(a).end()

pair<int, int> n(const string &s, int i) {
  int nv = 0;
  if (s[i] == '0') return make_pair(0, i+1);
  if (!isdigit(s[i])) throw "invalid";
  while (i < s.size() && isdigit(s[i])) {
    nv *= 2;
    nv += s[i] - '0';
    ++i;
  }
  return make_pair(nv, i);
}

pair<int, int> e(const string &s, int i);

pair<int, int> f(const string &s, int i) {
  if (i >= s.size()) throw "invalid";
  if (s[i] == '-') {
    int fv;
    tie(fv, i) = f(s, i+1);
    return make_pair(-fv, i);
  } else if (s[i] == '(') {
    int ev;
    tie(ev, i) = e(s, i+1);
    if (i >= s.size() || s[i] != ')') throw "invalid";
    return make_pair(ev, i+1);
  }
  return n(s, i);
}

pair<int, int> t(const string &s, int i) {
  int fl;
  tie(fl, i) = f(s, i);
  while (i < s.size()-1 && s[i] == '*') {
    int fr;
    tie(fr, i) = f(s, i+1);
    fl *= fr;
  }
  return make_pair(fl, i);
}

pair<int, int> e(const string &s, int i) {
  int tl;
  tie(tl, i) = t(s, i);
  while (i < s.size()-1 && (s[i] == '+' || s[i] == '-')) {
    char op = s[i];
    int tr;
    tie(tr, i) = t(s, i+1);
    if (op == '+') {
      tl += tr;
    } else {
      tl -= tr;
    }
  }
  return make_pair(tl, i);
}

bool valid(const string &s) {
  int i = 0;
  int e1, e2;
  tie(e1, i) = e(s, i);
  if (i >= s.size() || s[i] != '=') throw "invalid";
  tie(e2, i) = e(s, i+1);
  if (i != s.size()) throw "invalid";
  return e1 == e2;
}

int frac(int i) {
  if (i == 0) return 1;
  return i * frac(i-1);
}

int main(){
  string ch = "01()+-=*";
  sort(ALL(ch));
  string s;
  cin>>s;
  int cnt=0;
  vector<char> let;
  for (char c : s) {
    if (find(ALL(ch), c) == end(ch)) {
      let.push_back(c);
    }
  }
  sort(ALL(let));
  let.erase(unique(ALL(let)), end(let));
  if (let.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  map<char, int> idx;
  REP(i,let.size()) {
    idx[let[i]] = i;
  }
  do {
    string t = s;
    for (char &c : t) {
      if (idx.count(c)) {
        c = ch[idx[c]];
      }
    }
    try {
      if (valid(t)) {
        ++cnt;
      }
    } catch(...) {
    }
  } while (next_permutation(ALL(ch)));
  cout << cnt/frac(ch.size() - let.size()) << endl;
  return 0;
}