#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
pair<string, string> split(const string &s) {
  int p = s.find('=');
  string l = s.substr(0, p);
  string r = s.substr(p + 1);
  return make_pair(l, r);
}
bool check(const string &s) {
  int p = s.find('=');
  if(p == -1) return false;
  pair<string, string> sp = split(s);
  if(sp.first.size() == 0 || sp.second.size() == 0) return false;
  int k = 0;
  for(char c : sp.first) {
    if(c == '(') ++k;
    if(c == ')') --k;
    if(k < 0) return false;
  }
  if(k != 0) return false;
  for(char c : sp.second) {
    if(c == '(') ++k;
    if(c == ')') --k;
    if(k < 0) return false;
  }
  return true;
}
typedef string::const_iterator iter;
struct Result {
  bool valid;
  int value;
  Result(bool valid_, int value_) : valid(valid_), value(value_) {}
};
Result fail(false, 114514);
bool Q(iter &p);
Result E(iter &p);
Result T(iter &p);
Result F(iter &p);
Result N(iter &p);
Result B(iter &p);
bool Q(iter &p) {
  Result l = E(p);
  // if(!l.valid) {
  //   cerr << "l = No" << endl;
  // }
  // else {
  //   cerr << "l = " << l.value << endl;
  // }
  if(!l.valid) return false;
  if(*p != '=') return false;
  ++p;
  Result r = E(p);
  // if(!l.valid) {
  //   cerr << "r = No" << endl;
  // }
  // else {
  //   cerr << "r = " << r.value << endl;
  // }
  if(!r.valid) return false;
  if(*p != '\0') return false;
  return l.value == r.value;
}
Result E(iter &p) {
  Result t = T(p);
  if(!t.valid) return fail;
  while(true) {
    if(*p == '+') {
      ++p;
      Result s = T(p);
      if(!s.valid) return fail;
      t.value += s.value;
    }
    else if(*p == '-') {
      ++p;
      Result s = T(p);
      if(!s.valid) return fail;
      t.value -= s.value;
    }
    else {
      break;
    }
  }
  return t;
}
Result T(iter &p) {
  Result t = F(p);
  if(!t.valid) return fail;
  while(true) {
    if(*p == '*') {
      ++p;
      Result s = F(p);
      if(!s.valid) return fail;
      t.value *= s.value;
    }
    else {
      break;
    }
  }
  return t;
}
Result F(iter &p) {
  if(*p == '(') {
    ++p;
    Result e = E(p);
    if(*p != ')') {
      return fail;
    }
    ++p;
    return e;
  }
  else if(*p == '-') {
    ++p;
    Result e = F(p);
    if(!e.valid) return fail;
    e.value *= -1;
    return e;
  }
  return N(p);
}
Result N(iter &p) {
  if(!isdigit(*p)) {
    return fail;
  }
  int n = 0;
  int i = 0;
  while(isdigit(*p)) {
    n *= 2;
    if(i > 0 && n == 0) return fail;
    n += *p - '0';
    ++p;
    ++i;
  }
  // DEBUG(n);
  return Result(true, n);
}
void dbg() {
  string S; cin >> S;
  iter p = S.cbegin();
  bool r = Q(p);
  cout << (r ? "Yes" : "No") << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  if(false) {
    dbg();
  }
  else {
    string S; cin >> S;
    vector<char> ch;
    string ops = "01+-*=()";
    sort(ops.begin(), ops.end());
    REP(i,S.size()) {
      if(ops.find(S[i]) == string::npos) {
        ch.push_back(S[i]);
      }
    }
    sort(ch.begin(), ch.end());
    ch.erase(unique(ch.begin(), ch.end()), ch.end());
    if(ch.size() > 8) {
      cout << 0 << endl;
      return 0;
    }
    map<char, int> replacer;
    REP(i,ch.size()) {
      replacer[ch[i]] = i;
      // DEBUG(ch[i]);
    }
    set<string> ans;
    do {
      string T = S;
      REP(i,T.size()) {
        if(replacer.count(T[i])) T[i] = ops[replacer[T[i]]];
      }
      // if(T == "-0=(0)") DEBUG(T);
      iter p = T.cbegin();
      bool r = Q(p);
      if(r) {
        ans.insert(ops.substr(0,ch.size()));
        // DEBUG(T);
      }
    } while(next_permutation(ops.begin(), ops.end()));
    cout << ans.size() << endl;
  }
}

Measured memory_bytes: 3216