#include <bits/stdc++.h>
using namespace std;
string s, t;
int n;
vector<char> cs, match;
string cand = "01+-*()=";
bool used[10];
int res = 0;
int calc_e(int& l, int term);
int calc_f(int& l, int term) {
  if (l >= term) return -INT_MAX;
  if (isdigit(t[l])) {
    int v = 0;
    if (t[l] == '0' && l + 1 < term && isdigit(t[l + 1])) return -INT_MAX;
    while (l < term && isdigit(t[l])) {
      v <<= 1;
      v += t[l] - '0';
      l++;
    }
    return v;
  } else if (t[l] == '-') {
    l++;
    int v = calc_f(l, term);
    if (v == -INT_MAX) return -INT_MAX;
    return -v;
  } else if (t[l] == '(') {
    l++;
    int v = calc_e(l, term);
    if (v == -INT_MAX || t[l] != ')') return -INT_MAX;
    l++;
    return v;
  } else {
    return -INT_MAX;
  }
}
int calc_t(int& l, int term) {
  if (l >= term) return -INT_MAX;
  int v = calc_f(l, term);
  if (v == -INT_MAX || l > term) return -INT_MAX;
  while (l < term && t[l] == '*') {
    l++;
    int nv = calc_f(l, term);
    if (nv == -INT_MAX) return -INT_MAX;
    v *= nv;
  }
  return v;
}
int calc_e(int& l, int term) {
  if (l >= term) return -INT_MAX;
  int v = calc_t(l, term);
  if (v == -INT_MAX || l > term) return -INT_MAX;
  while (l < term && (t[l] == '+' || t[l] == '-')) {
    if (t[l] == '+') {
      l++;
      int nv = calc_t(l, term);
      if (nv == -INT_MAX) return -INT_MAX;
      v += nv;
    } else if (t[l] == '-') {
      l++;
      int nv = calc_t(l, term);
      if (nv == -INT_MAX) return -INT_MAX;
      v -= nv;
    }
  }
  return v;
}
void dfs(int i) {
  if (i == cs.size()) {
    t = "";
    for (long long j = (long long)(0); j < (long long)(s.size()); j++) {
      if ((find((cand).begin(), (cand).end(), s[j]) != cand.end())) {
        t += s[j];
        continue;
      }
      for (long long k = (long long)(0); k < (long long)(cs.size()); k++) {
        if (s[j] == cs[k]) {
          t += match[k];
          break;
        }
      }
    }
    int cnt = 0;
    for (long long j = (long long)(0); j < (long long)(t.size()); j++) {
      if (t[j] == '=') cnt++;
    }
    if (cnt != 1) return;
    for (long long j = (long long)(0); j < (long long)(t.size()); j++) {
      if (t[j] == '=') {
        int l = 0, r = j + 1;
        int cntc = 0;
        bool ok = true;
        for (long long k = (long long)(l); k < (long long)(j); k++) {
          if (t[k] == '(') cntc++;
          if (t[k] == ')') cntc--;
          if (cntc < 0) ok = false;
        }
        if (cntc != 0) ok = false;
        cntc = 0;
        for (long long k = (long long)(r); k < (long long)(n); k++) {
          if (t[k] == '(') cntc++;
          if (t[k] == ')') cntc--;
          if (cntc < 0) ok = false;
        }
        if (cntc != 0) ok = false;
        if (!ok) break;
        int vl = calc_e(l, j);
        int vr = calc_e(r, n);
        if (vl != -INT_MAX && vr != -INT_MAX && vl == vr) {
          res++;
        }
        break;
      }
    }
    return;
  }
  for (long long j = (long long)(0); j < (long long)(cand.size()); j++) {
    if (used[j]) continue;
    used[j] = true;
    match.push_back(cand[j]);
    dfs(i + 1);
    match.pop_back();
    used[j] = false;
  }
}
int main() {
  cin >> s;
  n = s.size();
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if ((find((cand).begin(), (cand).end(), s[i]) != cand.end())) continue;
    cs.push_back(s[i]);
  }
  sort((cs).begin(), (cs).end());
  cs.erase(unique((cs).begin(), (cs).end()), cs.end());
  if (cs.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  dfs(0);
  cout << res << endl;
  return 0;
}
