#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, size_t N, class T>
void Fill(A (&a)[N], const T &v) {
  fill((T *)a, (T *)(a + N), v);
}
const int INF = 0x3fffffff;
bool flag;
int B(string &s, int &n) {
  int ret = 1;
  while (1) {
    if (s.size() <= n) {
      break;
    } else if (s[n] == '0') {
      n++;
      ret <<= 1;
    } else if (s[n] == '1') {
      n++;
      ret <<= 1;
      ret += 1;
    } else {
      break;
    }
  }
  return ret;
}
int N(string &s, int &n) {
  if (s.size() <= n) {
    flag = false;
    return 0;
  } else if (s[n] == '0') {
    n++;
    return 0;
  } else if (s[n] == '1') {
    n++;
    return B(s, n);
  }
  flag = false;
  return 0;
}
int E(string &s, int &n);
int F(string &s, int &n) {
  if (s.size() <= n) {
    flag = false;
    return 0;
  }
  int ret;
  if (s[n] == '0' || s[n] == '1') {
    ret = N(s, n);
  } else if (s[n] == '-') {
    n++;
    ret = -F(s, n);
  } else if (s[n] == '(') {
    n++;
    ret = E(s, n);
    if (s[n] == ')')
      n++;
    else
      flag = false;
  } else {
    flag = false;
  }
  return ret;
}
int T(string &s, int &n) {
  if (s.size() <= n) {
    flag = false;
    return 0;
  }
  int ret = F(s, n);
  if (s.size() <= n) {
  } else if (s[n] == '*') {
    n++;
    ret += T(s, n);
  } else if (s[n] == '+' || s[n] == '-' || s[n] == '=' || s[n] == ')')
    ;
  else
    flag = false;
  return ret;
}
int E(string &s, int &n) {
  int ret = T(s, n);
  if (s.size() <= n) {
    return ret;
  } else if (s[n] == '+') {
    n++;
    ret += E(s, n);
  } else if (s[n] == '-') {
    n++;
    ret -= E(s, n);
  } else if (s[n] == '=') {
  } else if (s[n] == ')') {
  } else
    flag = false;
  return ret;
}
bool Q(string &s) {
  flag = true;
  int n = 0;
  int l = E(s, n);
  if (s[n] != '=') return false;
  n++;
  if (s.size() <= n) return false;
  int r = E(s, n);
  if (s.size() != n) flag = false;
  return flag && l == r;
}
vector<char> ope = {'0', '1', '+', '-', '*', '(', ')', '='};
int main() {
  set<string> ans;
  string S;
  cin >> S;
  vector<char> v;
  for (char c : S) {
    if ('A' <= c && c <= 'Z') v.push_back(c);
    if ('a' <= c && c <= 'z') v.push_back(c);
  }
  v.erase(unique((v).begin(), (v).end()), v.end());
  if (v.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  sort((ope).begin(), (ope).end());
  do {
    char mp[256] = {};
    for (int i = 0; i < (v.size()); i++) mp[v[i]] = ope[i];
    string s;
    for (char c : S) s += mp[c] ? mp[c] : c;
    if (Q(s)) ans.insert(s);
  } while (next_permutation((ope).begin(), (ope).end()));
  cout << ans.size() << endl;
  return 0;
}
