#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
bool err;
string e;
ll N(int l, int r);
ll F(int l, int r);
ll T(int l, int r);
ll E(int l, int r);
ll N(int l, int r) {
  if (l > r) {
    err = true;
    return 0;
  }
  ll ret = 0;
  for (int i = l; i <= r; ++i) {
    if (e[i] == '0' || e[i] == '1')
      ret = ret * 2 + e[i] - '0';
    else {
      err = true;
      return 0;
    }
  }
  if (e[l] == '0') {
    if (l != r) err = true;
  }
  return ret;
}
ll F(int l, int r) {
  if (l > r) {
    err = true;
    return 0;
  }
  if (e[l] == '(') {
    if (e[r] != ')') err = true;
    return E(l + 1, r - 1);
  } else if (e[l] == '-') {
    return -F(l + 1, r);
  } else
    return N(l, r);
}
ll T(int l, int r) {
  if (l > r) {
    err = true;
    return 0;
  }
  int b = 0;
  int a_pos = -1;
  for (int i = r; i >= l; --i) {
    if (e[i] == ')')
      ++b;
    else if (e[i] == '(')
      --b;
    if (e[i] == '*') {
      if (b == 0) {
        a_pos = i;
        break;
      }
    }
  }
  if (a_pos == -1)
    return F(l, r);
  else
    return T(l, a_pos - 1) * F(a_pos + 1, r);
}
ll E(int l, int r) {
  if (l > r) {
    err = true;
    return 0;
  }
  char op = '?';
  int o_pos = -1;
  int b = 0;
  for (int i = r; i >= l; --i) {
    if (e[i] == ')')
      ++b;
    else if (e[i] == '(')
      --b;
    if (e[i] == '+' && b == 0) {
      o_pos = i;
      op = '+';
      break;
    }
  }
  if (op != '+') {
    b = 0;
    for (int i = r; i >= l; --i) {
      if (e[i] == ')')
        ++b;
      else if (e[i] == '(')
        --b;
      if (e[i] == '-' && b == 0) {
        o_pos = i;
        while (l <= o_pos && e[o_pos] == '-') --o_pos;
        if (o_pos < l) {
          op = '?';
          break;
        } else {
          ++o_pos;
          op = '-';
          break;
        }
      }
    }
  }
  if (op == '?')
    return T(l, r);
  else if (op == '+')
    return E(l, o_pos - 1) + T(o_pos + 1, r);
  else
    return E(l, o_pos - 1) - T(o_pos + 1, r);
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  set<char> a;
  for (char c : s) {
    if (islower(c) || isupper(c)) a.insert(c);
  }
  if (a.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  string x = "01+-*()=";
  sort((x).begin(), (x).end());
  set<string> valid;
  set<string> check;
  do {
    auto itr = x.begin();
    map<char, char> cv;
    for (char c : a) {
      cv[c] = *itr;
      ++itr;
    }
    string t = s;
    for (int(i) = 0; (i) < (int)(n); ++(i))
      if (cv.count(t[i])) t[i] = cv[t[i]];
    int eq = 0;
    int e_pos = -1;
    for (int(i) = 0; (i) < (int)(n); ++(i)) {
      if (t[i] == '=') {
        ++eq;
        e_pos = i;
      }
    }
    if (eq != 1) continue;
    string l = t.substr(0, e_pos);
    string r = t.substr(e_pos + 1);
    if (l.size() == 0 || r.size() == 0) continue;
    err = false;
    e = l;
    ll L = E(0, e.size() - 1);
    e = r;
    ll R = E(0, e.size() - 1);
    if (!err && L == R) valid.insert(t);
    if (!err) check.insert(t);
  } while (next_permutation((x).begin(), (x).end()));
  cout << valid.size() << endl;
  return 0;
}
