#include <bits/stdc++.h>
using namespace std;
string S = "()01+-*=";
bool flag = false;
int n;
string s;
int F(int &id);
int E(int &id);
int getnum(int &id) {
  int cnt = 0, num = 0;
  bool firstzero = s[id] == '0';
  while (id < n && (s[id] == '0' || s[id] == '1')) {
    num *= 2;
    num += (s[id] - '0');
    id++;
    cnt++;
  }
  if (firstzero && cnt > 1) {
    flag = false;
  }
  return num;
}
int F(int &id) {
  if (id < n) {
    if (s[id] == '0' || s[id] == '1')
      return getnum(id);
    else if (s[id] == '(') {
      id++;
      int num = E(id);
      if (id < n && s[id] == ')') {
        id++;
        return num;
      }
    } else if (s[id] == '-') {
      id++;
      return -F(id);
    }
  }
  flag = false;
  return 0;
}
int T(int &id) {
  int sum = 1;
  if (s[id] == '(' || s[id] == '-' || s[id] == '0' || s[id] == '1')
    sum *= F(id);
  else {
    flag = false;
    return 0;
  }
  if (!flag) return false;
  if (id == n || s[id] == ')' || s[id] == '=' || s[id] == '+' || s[id] == '-') {
    return sum;
  }
  if (s[id] == '*') {
    id++;
    return sum * T(id);
  } else {
    flag = false;
    return 0;
  }
}
int E(int &id) {
  int sum = 0;
  if (s[id] == '(' || s[id] == '-' || s[id] == '0' || s[id] == '1')
    sum += T(id);
  else {
    flag = false;
    return 0;
  }
  if (!flag) return false;
  if (id == n || s[id] == ')' || s[id] == '=') {
    return sum;
  }
  if (s[id] == '+') {
    id++;
    return sum + E(id);
  } else if (s[id] == '-') {
    id++;
    return sum - E(id);
  } else {
    flag = false;
    return 0;
  }
}
bool Q() {
  int L, R;
  flag = true;
  int eq = -1, id;
  for (int i = (0); i < (n); i++) {
    if (s[i] == '=') {
      if (eq == -1)
        eq = i;
      else
        return false;
    }
  }
  if (eq == -1) return false;
  L = E(id = 0);
  if (!flag || id != eq) return false;
  R = E(id = eq + 1);
  if (!flag || id != n) return false;
  return L == R;
}
int main() {
  flag = true;
  map<char, int> m;
  string input;
  cin >> input;
  n = input.size();
  s = input;
  for (int i = (0); i < (n); i++) {
    bool exist = false;
    for (int j = (0); j < (8); j++)
      if (s[i] == S[j]) exist = true;
    if (!exist) m[s[i]] = 0;
  }
  int cnt = 0;
  for (auto &it : m) it.second = cnt++;
  if (cnt > 8) {
    cout << 0 << endl;
    return 0;
  }
  set<string> all;
  vector<int> ord(8);
  iota(ord.begin(), ord.end(), 0);
  do {
    for (int i = (0); i < (n); i++) {
      if (m.count(input[i])) s[i] = S[ord[m[input[i]]]];
    }
    all.insert(s);
  } while (next_permutation(ord.begin(), ord.end()));
  int res = 0;
  for (auto &it : all) {
    s = it;
    if (Q()) res++;
  }
  cout << res << endl;
  return 0;
}
