#include <bits/stdc++.h>
using namespace std;
pair<int, int> isE(const std::string &s, int start, int end);
pair<int, int> isB(const std::string &s, int start) {
  pair<int, int> p;
  int x = 0;
  if (s[start] != '0' && s[start] != '1') {
    return make_pair(-1, -1);
  }
  if (s[start] == '0') {
    return make_pair(0, start + 1);
  }
  while (start < s.length() && (s[start] == '0' || s[start] == '1')) {
    x = x << 1;
    x += s[start] - '0';
    start++;
  }
  return make_pair(x, start);
}
pair<int, int> isF(const std::string &s, int start, int end) {
  if (start >= end) return make_pair(-1, -1);
  if (s[start] == '(') {
    if (s[end - 1] != ')') return make_pair(-1, -1);
    pair<int, int> p = isE(s, start + 1, end - 1);
    if (p.second == -1) return p;
    return make_pair(p.first, p.second + 1);
  }
  if (s[start] == '-') {
    pair<int, int> p = isF(s, start + 1, end);
    if (p.second == -1) return p;
    if (p.second != end) return make_pair(-1, -1);
    p.first *= -1;
    return p;
  }
  pair<int, int> p = isB(s, start);
  if (p.second == end) return p;
  return make_pair(-1, -1);
}
pair<int, int> isT(const std::string &s, int start, int end) {
  for (int i = end - 1; i > start; --i) {
    if (s[i] == '*') {
      pair<int, int> p = isF(s, i + 1, end);
      if (p.second == -1) continue;
      pair<int, int> q = isT(s, start, i);
      if (q.second == -1) continue;
      return make_pair(p.first * q.first, end);
    }
  }
  pair<int, int> p = isF(s, start, end);
  return p;
}
pair<int, int> isE(const std::string &s, int start, int end) {
  if (start >= end) return make_pair(-1, -1);
  for (int i = end - 1; i > start; --i) {
    if (s[i] == '+' || s[i] == '-') {
      pair<int, int> p = isT(s, i + 1, end);
      if (p.second == -1) continue;
      pair<int, int> q = isE(s, start, i);
      if (q.second == -1) continue;
      if (s[i] == '+') {
        return make_pair(p.first + q.first, end);
      }
      if (s[i] == '-') {
        return make_pair(q.first - p.first, end);
      }
    }
  }
  pair<int, int> p = isT(s, start, end);
  return p;
}
bool isQ(const std::string &s) {
  int idx = -1;
  for (int i = 1; i < s.length() - 1; ++i) {
    if (s[i] == '=') {
      idx = i;
      break;
    }
  }
  if (idx == -1) return false;
  pair<int, int> p = isE(s, 0, idx);
  if (p.second == -1 || s[p.second] != '=') return false;
  pair<int, int> q = isE(s, p.second + 1, s.length());
  if (q.second == -1) return false;
  return p.first == q.first;
}
bool check(const std::string &s) { return isQ(s); }
int main() {
  string s;
  cin >> s;
  std::vector<char> ops = {'=', '+', '-', '*', '(', ')', '0', '1'};
  sort(ops.begin(), ops.end());
  std::set<char> chars;
  for (int i = 0; i < s.length(); ++i) {
    if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
      chars.insert(s[i]);
    }
  }
  std::vector<char> abc;
  for (const char c : chars) abc.push_back(c);
  if (abc.size() > ops.size()) {
    cout << "0" << endl;
    return 0;
  }
  std::map<char, char> m;
  for (int i = 0; i < ops.size(); ++i) m[ops[i]] = ops[i];
  std::set<string> ans;
  do {
    for (int i = 0; i < abc.size(); ++i) m[abc[i]] = ops[i];
    string ss = s;
    for (int i = 0; i < s.length(); ++i) ss[i] = m[s[i]];
    if (check(ss)) {
      ans.insert(ss);
    }
  } while (next_permutation(ops.begin(), ops.end()));
  cout << ans.size() << endl;
}
