#include <bits/stdc++.h>
using namespace std;
string s, str;
int p, ans, flag;
char c[8] = {'0', '1', '+', '-', '*', '(', ')', '='};
char memo[400];
bool isalph(char ch) {
  return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'));
}
int bnf();
int bnf3() {
  if (s[p] == ')') flag = 1;
  if (s[p] == '*' || s[p] == '+') flag = 1;
  if (s[p] == '(') {
    p++;
    if (s[p] == ')') flag = 1;
    int r = bnf();
    if (p >= s.size() || s[p] != ')') flag = 1;
    p++;
    return r;
  }
  int res = 0, min = 0;
  if (s[p] == '0' && p + 1 < s.size() && (s[p + 1] == '0' || s[p + 1] == '1'))
    flag = 1;
  if (s[p] == '-') {
    while (s[p] == '-') min++, p++;
    if (s[p] == '(') {
      p++;
      int r = bnf();
      if (min % 2) r *= -1;
      return r;
    } else if (!('0' <= s[p] && s[p] <= '1'))
      flag = 1;
  } else if (!('0' <= s[p] && s[p] <= '1'))
    flag = 1;
  while ('0' <= s[p] && s[p] <= '1') res = res * 2 + s[p] - '0', p++;
  if (s[p] == '(') flag = 1;
  if (min % 2) res *= -1;
  return res;
}
int bnf2() {
  int res = bnf3();
  while (p < s.size()) {
    if (s[p] == '*') {
      p++;
      if (s[p] == ')' || s[p] == '*' || s[p] == '+') flag = 1;
      int r = bnf3();
      res *= r;
    } else
      break;
  }
  return res;
}
int bnf() {
  int res = bnf2();
  while (p < s.size()) {
    if (s[p] == '+') {
      p++;
      if (s[p] == ')' || s[p] == '+' || s[p] == '*') flag = 1;
      int r = bnf2();
      res += r;
    } else if (s[p] == '-') {
      p++;
      if (s[p] == ')' || s[p] == '*' || s[p] == '+') flag = 1;
      int r = bnf2();
      res -= r;
    } else
      break;
  }
  return res;
}
void check() {
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') cnt++;
    if (s[i] == ')') {
      if (cnt == 0) {
        flag = 1;
        return;
      } else
        cnt--;
    }
  }
  if (cnt) flag = 1;
}
set<string> me;
void solve() {
  set<char> S;
  for (int i = 0; i < s.size(); i++)
    if (isalph(s[i])) S.insert(s[i]);
  set<char>::iterator ite = S.begin();
  vector<char> al;
  while (ite != S.end()) {
    al.push_back((*ite));
    ite++;
  }
  if (al.size() > 8) {
    cout << 0 << endl;
    return;
  }
  int idx[8];
  for (int i = 0; i < 8; i++) idx[i] = i;
  do {
    for (int i = 0; i < al.size(); i++) memo[al[i]] = c[idx[i]];
    s = "";
    for (int i = 0; i < str.size(); i++) {
      if (S.count(str[i]))
        s += memo[str[i]];
      else
        s += str[i];
    }
    if (me.count(s)) continue;
    me.insert(s);
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == '=') cnt++;
    if (cnt != 1) continue;
    string s1, s2;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '=') break;
      s1 += s[i];
    }
    int f = 0;
    for (int i = 0; i < s.size(); i++) {
      if (f) s2 += s[i];
      if (s[i] == '=') f = 1;
    }
    flag = 0;
    s = s1;
    p = 0;
    int r1 = bnf();
    check();
    s = s2;
    p = 0;
    int r2 = bnf();
    check();
    if (!flag && s1.size() && s2.size() && r1 == r2) ans++;
  } while (next_permutation(idx, idx + 8));
}
int main() {
  cin >> s;
  str = s;
  solve();
  cout << ans << endl;
  return 0;
}
