#include <bits/stdc++.h>
using namespace std;
string letters = "01+-*()=";
string s;
class Equation {
  string s;

 public:
  void init(string s) { this->s = s; }
  bool Q(int l, int r) {
    int i;
    int cnt = 0;
    for (i = l; i < r; i++) cnt += (s[i] == '=');
    if (cnt != 1) return false;
    for (i = l; i < r; i++) {
      if (s[i] == '=') break;
    }
    pair<bool, int> res1 = E(l, i);
    if (!res1.first) return false;
    pair<bool, int> res2 = E(i + 1, r);
    if (!res2.first) return false;
    return (res1.second == res2.second);
  }
  pair<bool, int> E(int l, int r) {
    if (l >= r) return pair<bool, int>(false, 0);
    if (T(l, r).first) return T(l, r);
    int lv = 0, i;
    for (i = r - 1; i >= l; i--) {
      if (s[i] == ')') lv++;
      if (s[i] == '(') lv--;
      if (lv == 0 && (s[i] == '+' || s[i] == '-')) {
        pair<bool, int> res1 = E(l, i);
        if (!res1.first) return pair<bool, int>(false, 0);
        pair<bool, int> res2 = T(i + 1, r);
        if (!res2.first) return pair<bool, int>(false, 0);
        if (s[i] == '+')
          return pair<bool, int>(true, res1.second + res2.second);
        return pair<bool, int>(true, res1.second - res2.second);
      }
    }
  }
  pair<bool, int> T(int l, int r) {
    if (l >= r) return pair<bool, int>(false, 0);
    int lv = 0, i;
    for (int i = r - 1; i >= l; i--) {
      if (s[i] == ')') lv++;
      if (s[i] == '(') lv--;
      if (lv == 0 && s[i] == '*') {
        pair<bool, int> res1 = T(l, i);
        if (!res1.first) return pair<bool, int>(false, 0);
        pair<bool, int> res2 = F(i + 1, r);
        if (!res2.first) return pair<bool, int>(false, 0);
        return pair<bool, int>(true, res1.second * res2.second);
      }
    }
    return F(l, r);
  }
  pair<bool, int> F(int l, int r) {
    if (l >= r) return pair<bool, int>(false, 0);
    if (s[l] == '(' && s[r - 1] == ')') return E(l + 1, r - 1);
    if (s[l] == '-') {
      pair<bool, int> res = F(l + 1, r);
      return pair<bool, int>(res.first, -res.second);
    }
    return N(l, r);
  }
  pair<bool, int> N(int l, int r) {
    if (l >= r) return pair<bool, int>(false, 0);
    for (int i = l; i < r; i++)
      if (s[i] != '0' && s[i] != '1') return pair<bool, int>(false, 0);
    if (s[l] == '0') {
      if (r - l == 1) return pair<bool, int>(true, 0);
      return pair<bool, int>(false, 0);
    }
    int val = 0;
    for (int i = l; i < r; i++) {
      val *= 2;
      val += s[i] - '0';
    }
    return pair<bool, int>(true, val);
  }
};
Equation equation;
int main() {
  cin >> s;
  bool used[256] = {false};
  int toId[256];
  int uCnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (used[s[i]] == false) {
      used[s[i]] = true;
      int j;
      for (j = 0; j < 8; j++)
        if (letters[j] == s[i]) break;
      if (j < 8) {
        toId[s[i]] = -1;
      } else {
        toId[s[i]] = uCnt++;
      }
    }
    if (uCnt > 8) {
      cout << 0 << endl;
      return 0;
    }
  }
  set<string> dict;
  vector<int> perm;
  for (int i = 0; i < 8; i++) perm.push_back(i);
  do {
    string letters2;
    for (int i = 0; i < 8; i++) {
      letters2 += letters[perm[i]];
    }
    string ss;
    for (int i = 0; i < s.length(); i++) {
      if (toId[s[i]] == -1) {
        ss += s[i];
      } else {
        ss += letters2[toId[s[i]]];
      }
    }
    dict.insert(ss);
  } while (next_permutation(perm.begin(), perm.end()));
  int ans = 0;
  for (set<string>::iterator it = dict.begin(); it != dict.end(); it++) {
    equation.init((*it));
    if (equation.Q(0, (*it).length())) {
      ans++;
    }
  }
  if (s.length() > 4 && ans >= 10) assert(0);
  cout << ans << endl;
  return 0;
}
