#include <bits/stdc++.h>
using namespace std;
int expression(string::const_iterator &begin);
int data[8];
int used[8];
int res;
map<char, int> mp;
string keydata = "01()+-*=";
int expression(string::const_iterator &begin);
int number(string::const_iterator &begin) {
  int ret = 0;
  while (isdigit(*begin)) {
    ret *= 2;
    ret += *begin - '0';
    begin++;
  }
  return ret;
}
int factor(string::const_iterator &begin) {
  if (*begin == '-') {
    begin++;
    int ret;
    if (*begin == '(') {
      begin++;
      int ret = -expression(begin);
      begin++;
    } else {
      ret = -number(begin);
    }
    return ret;
  } else if (*begin == '(') {
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  } else {
    return number(begin);
  }
}
int term(string::const_iterator &begin) {
  int ret = factor(begin);
  while (1) {
    if (*begin == '*') {
      begin++;
      ret *= factor(begin);
    } else
      break;
  }
  return ret;
}
int expression(string::const_iterator &begin) {
  int ret = term(begin);
  while (1) {
    if (*begin == '+') {
      begin++;
      ret += term(begin);
    } else if (*begin == '-') {
      begin++;
      ret -= term(begin);
    } else
      break;
  }
  return ret;
}
int num[101];
bool check(string s) {
  int cc = 0;
  memset(num, 0, sizeof(num));
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '-') {
      if (i + 1 == s.size()) return false;
      if (i == 0) continue;
      if ((s[i - 1] == '+' || s[i - 1] == '*')) return false;
    }
    if (s[i] == '+' || s[i] == '*') {
      if (i == 0 || i + 1 == s.size()) return false;
      if (!(isdigit(s[i - 1]) || s[i - 1] == ')')) return false;
    }
    if (s[i] == '(') {
      cc++;
      if (i + 1 == s.size()) return false;
      if (i >= 1 && (s[i - 1] == ')' || isdigit(s[i - 1]))) return false;
    }
    if (isdigit(s[i])) {
      if (i >= 1 && (s[i - 1] == ')')) return false;
      if (i >= 1 && s[i] == '1' && s[i - 1] == '0') return false;
      if (i >= 1 && s[i] == '0' && s[i - 1] == '0') return false;
      num[cc]++;
    }
    if (s[i] == ')') {
      if (cc == 0) return false;
      if (num[cc] == 0) return false;
      if (!(s[i - 1] == ')' || isdigit(s[i - 1]))) return false;
      num[cc] = 0;
      cc--;
    }
  }
  if (cc != 0) return false;
  return true;
}
string str;
void dfs(int v) {
  if (v == mp.size()) {
    string tmp = "";
    for (int i = 0; i < str.size(); i++) {
      if ((str[i] >= 'a' && str[i] <= 'z') ||
          (str[i] >= 'A' && str[i] <= 'Z')) {
        int va = mp[str[i]];
        tmp += keydata[data[va - 1]];
      } else {
        tmp += str[i];
      }
    }
    string s1 = "";
    string s2 = "";
    bool eq = false;
    for (int i = 0; i < tmp.size(); i++) {
      if (tmp[i] == '=') {
        if (eq) return;
        eq = true;
      } else {
        if (!eq)
          s1 += tmp[i];
        else
          s2 += tmp[i];
      }
    }
    if (!check(s1) || s1.size() == 0) return;
    if (!check(s2) || s2.size() == 0) return;
    string::const_iterator s = s1.begin();
    int val = expression(s);
    s = s2.begin();
    int val2 = expression(s);
    if (val == val2) {
      res++;
    }
  } else {
    for (int i = 0; i < 8; i++) {
      if (used[i] == 0) {
        used[i] = 1;
        data[v] = i;
        dfs(v + 1);
        used[i] = 0;
      }
    }
  }
}
int main(void) {
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) {
      if (mp.find(str[i]) == mp.end()) {
        mp[str[i]] = mp.size();
      }
    }
  }
  dfs(0);
  printf("%d\n", res);
  return 0;
}
