#include <bits/stdc++.h>
using namespace std;
int len, p;
string S;
bool flag;
int compute();
int getNum() {
  if (p >= len) {
    flag = true;
    return 0;
  }
  if (S[p] == '-') {
    p++;
    return -getNum();
  } else if (S[p] == '0') {
    p++;
    return 0;
  } else if (S[p] == '1') {
    int res = 0;
    while (p < len && (S[p] == '0' || S[p] == '1')) {
      res *= 2;
      res += (S[p] - '0');
      p++;
    }
    return res;
  } else if (S[p] == '(') {
    p++;
    int res = compute();
    if (S[p - 1] != ')') flag = true;
    return res;
  } else {
    flag = true;
    return 0;
  }
}
int compute() {
  if (p >= len) {
    flag = true;
    return 0;
  }
  stack<int> st;
  while (p < len) {
    char ch = S[p];
    p++;
    if (ch == ')') break;
    int num = getNum();
    if (ch == '+') {
      st.push(num);
    } else if (ch == '-') {
      st.push(-num);
    } else if (ch == '*') {
      int x = st.top();
      st.pop();
      st.push(x * num);
    } else {
      flag = true;
      break;
    }
  }
  int res = 0;
  while (st.size() > 0) {
    res += st.top();
    st.pop();
  }
  return res;
}
int check(string str) {
  int cnt = 0, index;
  for (int i = 0; i < (int)str.size(); i++)
    if (str[i] == '=') cnt++, index = i;
  if (cnt != 1) return 0;
  if (index == 0 || index + 1 == (int)str.size()) return 0;
  flag = false;
  S = str.substr(0, index);
  p = 0;
  len = S.size();
  int lv = compute();
  if (flag || p < len) return 0;
  flag = false;
  S = str.substr(index + 1);
  p = 0;
  int rv = compute();
  if (flag || p < len) return 0;
  if (lv == rv)
    return 1;
  else
    return 0;
}
int solve(string str) {
  len = str.size();
  string tmp = "01+-*()=";
  sort(tmp.begin(), tmp.end());
  map<string, bool> used;
  int res = 0;
  do {
    map<char, char> mp;
    string s = str;
    for (int i = 0; i < len; i++) {
      if (s[i] < 'A') continue;
      if (s[i] > 'Z') continue;
      if (mp.count(s[i]) > 0)
        s[i] = mp[s[i]];
      else {
        int id = mp.size();
        mp[s[i]] = tmp[id];
        s[i] = tmp[id];
      }
      if (!used[s]) {
        used[s] = true;
        res += check(s);
      }
    }
  } while (next_permutation(tmp.begin(), tmp.end()));
  return res;
}
int main() {
  string str;
  cin >> str;
  cout << solve(str) << endl;
  return 0;
}
