#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <stdexcept>

const std::string TERMINAL = "01+-*()=";
const std::vector<std::string> OPS = {"+-", "*"};

int parse(const std::string& s, size_t& i, size_t preced=0) {
  if (preced == OPS.size()) {
    if (s[i] == '(') {
      int res = parse(s, ++i, 0);
      if (s[i] != ')') throw std::logic_error("expected: closing parenthesis");
      ++i;
      return res;
    }
    if (s[i] == '-') {
      return -parse(s, ++i, preced);
    }
    if (s[i] == '0') {
      ++i;
      if (isdigit(s[i]))
        throw std::logic_error("expected: leading-zero-free number");

      return 0;
    }
    if (isdigit(s[i])) {
      int res = s[i]-'0';
      while (++i < s.length() && isdigit(s[i]))
        res = res*2 + s[i]-'0';
      return res;
    }
    throw std::logic_error("unexpected token");
  }

  int lhs = parse(s, i, preced+1);
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(OPS[preced].begin(), OPS[preced].end(), op)) break;
    int rhs = parse(s, ++i, preced+1);
    if (op == '+') lhs += rhs;
    if (op == '-') lhs -= rhs;
    if (op == '*') lhs *= rhs;
  }
  return lhs;
}

void validate(const std::string& s) {
  size_t i = 0;
  int lhs = parse(s, i);
  if (s[i] != '=') throw std::logic_error("excepted: equal sign");
  ++i;
  int rhs = parse(s, i);
  if (i != s.length()) throw std::logic_error("expected: EOL");
  if (lhs != rhs) throw std::logic_error("not equal");

  // validated
}

int main() {
  char buf[32];
  scanf("%s", buf);
  std::string s = buf;

  std::set<char> alpha;
  for (char ch: s)
    if (isalpha(ch)) alpha.insert(ch);

  if (alpha.size() > TERMINAL.size())
    return puts("0"), 0;

  std::vector<char> t;
  for (char ch: TERMINAL) t.push_back(ch);
  std::sort(t.begin(), t.end());
  std::set<std::string> eq;
  do {
    std::map<char, char> enc;
    {
      size_t i = 0;
      for (auto it=alpha.begin(); it!=alpha.end(); ++it)
        enc[*it] = t[i++];
    }

    std::string s1 = s;
    for (char &c: s1)
      if (isalpha(c)) c = enc[c];

    try {
      validate(s1);
      eq.insert(s1);
    } catch (std::logic_error&) {
      void(0);
    }
  } while (std::next_permutation(t.begin() ,t.end()));

  printf("%zu\n", eq.size());
}

