#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
istream& operator>>(istream& is, pair<S, T>& p) {
  return is >> p.first >> p.second;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long MOD = 1e9 + 7;
int Q(int&);
int E(int&);
int T(int&);
int F(int&);
string S;
int N;
int err = 0;
string gs;
int Q(int& p) {
  int l = E(p);
  if (p >= N || gs[p] != '=') {
    err = 1;
    return 0;
  }
  ++p;
  int r = E(p);
  if (p != N) {
    err = 1;
    return 0;
  }
  return l == r;
}
int E(int& p) {
  int x = T(p);
  while (p < N) {
    if (gs[p] == '+') {
      ++p;
      x += T(p);
    } else if (gs[p] == '-') {
      ++p;
      x -= T(p);
    } else
      break;
  }
  return x;
}
int T(int& p) {
  int x = F(p);
  while (p < N) {
    if (gs[p] == '*') {
      ++p;
      x *= F(p);
    } else
      break;
  }
  return x;
}
int F(int& p) {
  if (p >= N) {
    err = 1;
    return 0;
  }
  int x = 0;
  if (gs[p] == '-') {
    ++p;
    x = -F(p);
  } else if (gs[p] == '(') {
    ++p;
    x = E(p);
    if (gs[p] != ')') {
      err = 1;
      return 0;
    }
    ++p;
  } else if (gs[p] == '0') {
    x = 0;
    ++p;
  } else if (gs[p] == '1') {
    x = 1;
    ++p;
    while (p < N) {
      if (gs[p] == '0')
        x *= 2;
      else if (gs[p] == '1')
        x = x * 2 + 1;
      else
        break;
      ++p;
    }
  } else {
    err = 1;
    return 0;
  }
  return x;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> S;
  N = int((S).size());
  map<char, int> s;
  for (int i = (0); i < (N); ++i) s[S[i]]++;
  if (int((s).size()) > 8) {
    cout << 0 << endl;
    return 0;
  }
  char cs[9] = "+-*=()01";
  sort(cs, cs + 8);
  set<string> ans;
  do {
    string tmp = S;
    int j = 0;
    for (int i = (0); i < (N); ++i) {
      char c = tmp[i];
      if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
        for (int k = (0); k < (N); ++k)
          if (tmp[k] == c) tmp[k] = cs[j];
        ++j;
      }
    }
    int p = 0;
    err = 0;
    gs = tmp;
    int flag = Q(p);
    if (flag && !err) ans.insert(gs);
  } while (next_permutation(cs, cs + 8));
  cout << int((ans).size()) << endl;
  return 0;
}
