// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

string s;

int expr(int &i);
int term(int &i);
int factor(int &i);
int number(int &i);

int expr(int &i) {
  int val = term(i);
  while (true) {
    if (s[i] == '+') {
      val += term(++i);
    } else if (s[i] == '-') {
      val -= term(++i);
    } else {
      break;
    }
  }
  return val;
}

int term(int &i) {
  int val = factor(i);
  while (true) {
    if (s[i] == '*') {
      val *= factor(++i);
    } else {
      break;
    }
  }
  return val;
}

int factor(int &i) {
  if (s[i] == '-') {
    return -factor(++i);
  } else if (s[i] == '(') {
    int val = expr(++i);
    if (s[i] != ')') throw "no right paren";
    ++i;
    return val;
  }
  return number(i);
}

int number(int &i) {
  if (not(s[i] == '0' || s[i] == '1')) throw "not 0 or 1";
  if (i + 1 < s.size() && s[i] == '0' && isdigit(s[i + 1])) throw "leading zero";

  int val = 0;
  while (isdigit(s[i])) {
    val <<= 1;
    val += s[i++] - '0';
  }
  return val;
}

main() {
  string S;
  cin >> S;
  vector<char> cs;
  for (auto &c : S) {
    if (isalpha(c)) cs.emplace_back(c);
  }
  sort(all(cs));
  cs.erase(unique(all(cs)), end(cs));
  string v = "01+-*=()";
  sort(all(v));
  if (v.size() < cs.size()) return cout << 0 << endl, 0;
  map<char, int> m;
  {
    int k = 0;
    for (auto &c : S) {
      if (isalpha(c) && not m.count(c)) m[c] = k++;
    }
  }
  set<string> done;
  int cnt = 0;
  do {
    s.clear();
    for (auto &c : S) s += isalpha(c) ? v[m[c]] : c;
    if (done.count(s)) continue;
    if (count(all(s), '=') != 1) continue;
    int l = 0, r = s.find('=') + 1, n = s.size();
    if (r == 1 || r == n) continue;
    done.emplace(s);
    try {
      int lhs = expr(l), rhs = expr(r);
      cnt += s[l] == '=' && r == n && lhs == rhs;
    } catch (...) {}
  } while (next_permutation(all(v)));
  cout << cnt << endl;
}



Measured memory_bytes: 7060