#include <bits/stdc++.h>
using namespace std;
char c[8] = {'0', '1', '+', '-', '*', '(', ')', '='};
vector<char> alph;
map<char, char> ralph;
string s;
int p;
int bnf();
int get_num() {
  if (s[p] == '(') {
    p++;
    int res = bnf();
    p++;
    return res;
  }
  int res = 0;
  while ('0' <= s[p] && s[p] <= '1') res = res * 2 + s[p] - '0', p++;
  return res;
}
int bnf2() {
  int res = get_num();
  while (p < s.size()) {
    if (s[p] == '*') {
      p++;
      res = res * get_num();
    } else
      break;
  }
  return res;
}
int bnf() {
  int res = bnf2();
  cout << res << ' ' << p << endl;
  while (p < s.size()) {
    if (s[p] == '+') {
      p++;
      res = res + bnf2();
    } else if (s[p] == '-') {
      p++;
      res = res - bnf2();
    } else
      break;
  }
  return res;
}
bool check() {
  int cnt = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == '=') cnt++;
  if (cnt != 1) return false;
  cnt = 0;
  int idx;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '=') {
      idx = i;
      break;
    }
    if (s[i] == '(') cnt++;
    if (s[i] == ')') {
      if (!cnt) return false;
      cnt--;
    }
  }
  if (cnt) return false;
  cnt = 0;
  for (int i = idx; i < s.size(); i++) {
    if (s[i] == '=') {
      idx = i;
      break;
    }
    if (s[i] == '(') cnt++;
    if (s[i] == ')') {
      if (!cnt) return false;
      cnt--;
    }
  }
  if (cnt) return false;
  for (int i = 0; i < s.size(); i++) {
    if (i && s[i] == '*' &&
        (s[i - 1] == '*' || s[i - 1] == '-' || s[i - 1] == '+'))
      return false;
    if (s[i] == '=' && (!i || i == s.size() - 1)) return false;
    if (s[i] == '=' && (s[i - 1] == '*' || s[i - 1] == '-' || s[i - 1] == '+' ||
                        s[i - 1] == '('))
      return false;
    if (s[i] == '=' && (s[i + 1] == '*' || s[i + 1] == '-' || s[i + 1] == '+' ||
                        s[i + 1] == ')'))
      return false;
  }
  return true;
}
set<string> memo;
int solve(string t) {
  if (alph.size() > 8) return 0;
  int idx[8];
  for (int i = 0; i < 8; i++) idx[i] = i;
  int res = 0;
  do {
    for (int i = 0; i < alph.size(); i++) ralph[alph[i]] = c[idx[i]];
    s = t;
    if (memo.count(s)) continue;
    memo.insert(s);
    for (int i = 0; i < s.size(); i++)
      if (ralph.count(s[i])) s[i] = ralph[s[i]];
    if (!check()) continue;
    string s1, s2;
    int f = 0;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == '=')
        f = 1;
      else if (!f)
        s1 += s[i];
      else
        s2 += s[i];
    s = s1;
    p = 0;
    int r = bnf();
    s = s2;
    p = 0;
    if (r == bnf()) res++;
  } while (next_permutation(idx, idx + 8));
  return res;
}
bool isalph(char A) { return ('a' <= A && A <= 'z') || ('A' <= A && A <= 'Z'); }
int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++)
    if (isalph(t[i])) alph.push_back(t[i]);
  solve(t);
  return 0;
}
