#include <bits/stdc++.h>
using namespace std;
string str;
int now;
int E();
int T();
int F();
int N();
int E() {
  int t = T();
  if (t == 2147483600) return 2147483600;
  if (str[now + 1] == '+') {
    now++;
    int p = E();
    if (p == 2147483600) return 2147483600;
    return t + p;
  }
  if (str[now + 1] == '-') {
    now++;
    int p = E();
    if (p == 2147483600) return 2147483600;
    return t - p;
  }
  return t;
}
int T() {
  int f = F();
  if (f == 2147483600) return 2147483600;
  if (str[now + 1] == '*') {
    now++;
    int g = T();
    if (g == 2147483600)
      return 2147483600;
    else
      return f * g;
  }
  return f;
}
int F() {
  int n;
  switch (str[now + 1]) {
    case '0':
    case '1':
      n = N();
      if (n == 2147483600)
        return 2147483600;
      else
        return n;
    case '-':
      now++;
      n = F();
      if (n == 2147483600)
        return 2147483600;
      else
        return -n;
    case '(':
      now++;
      n = E();
      if (str[now + 1] != ')' || n == 2147483600) return 2147483600;
      now++;
      return n;
    default:
      return 2147483600;
  }
}
int N() {
  if (str[now + 1] == '0') {
    now++;
    return 0;
  }
  if (str[now + 1] != '1') return 2147483600;
  now++;
  int res = 1;
  while (str[now + 1] == '1' || str[now + 1] == '0') {
    now++;
    res = res * 2 + str[now] - '0';
  }
  return res;
}
int main() {
  string s;
  cin >> s;
  set<char> m, mm;
  string moji = "=+-*()01";
  sort((moji).begin(), (moji).end());
  for (int i = (int)(0); i < (int)(s.size()); i++) {
    bool found = false;
    for (int j = (int)(0); j < (int)(moji.size()); j++)
      if (s[i] == moji[j]) {
        mm.insert(s[i]);
        found = true;
      }
    if (!found) m.insert(s[i]);
  }
  if (m.size() > moji.size()) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  do {
    bool flg = true;
    string newstr(s);
    int idx = 0;
    if (flg) {
      for (auto c : m) {
        for (int i = (int)(0); i < (int)(newstr.size()); i++)
          if (newstr[i] == c) {
            newstr[i] = moji[idx];
          }
        idx++;
      }
    }
    idx = newstr.find('=');
    if (newstr[0] == '=' || idx < 0) flg = false;
    if (flg) {
      str = newstr.substr(0, idx) + '\0';
      now = -1;
      int l = E();
      if (l != 2147483600 && now == idx - 1) {
        str = newstr.substr(idx + 1) + '\0';
        now = -1;
        int r = E();
        if (now == str.size() - 2 && r == l) ans++;
      }
    }
    reverse(moji.begin() + m.size(), moji.end());
  } while (next_permutation((moji).begin(), (moji).end()));
  cout << ans << endl;
  return 0;
}
