#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

bool Q();
int E();
int T();
int F();
int N();
string B();

string enc;
string str;
string alpha;
int idx;
int ans;

bool flag;

string sign = "01+-*()=";

bool isok(char c) {
  return idx < (int)str.size() && str[idx] == c;
}

bool Q() {
  flag = true;
  if(count(all(str), '=') != 1) return false;

  int lh = E();
  if(!flag) return false;
  if(!isok('=')) return false;
  idx++; // =

  int rh = E();
  if(!flag) return false;
  if(idx != (int)str.size()) return false;

  return lh == rh;
}

int E() {
  int res = T();
  if(!flag) return 0;
  while(flag && (isok('+') || isok('-'))) {
    int ope = (str[idx] == '+' ? 1 : -1);
    idx++; // +/-
    int ri = T();
    if(!flag) return 0;
    res += ope*ri;
  }
  return res;
}

int T() {
  int res = F();
  if(!flag) return 0;
  while(flag && isok('*')) {
    idx++;
    int ri = F();
    if(!flag) return 0;
    res *= ri;
  }
  return res;
}

int F() {
  if(isok('-')) {
    idx++;
    int res = F();
    if(!flag) return 0;
    return -res;
  }
  if(isok('(')) {
    idx++;
    int res = E();
    if(!flag) return 0;
    if(!isok(')')) { flag = false; return 0; }
    idx++; // )
    return res;
  }
  int res = N();
  if(!flag) return 0;
  return res;
}

int N() {
  string tmp = B();
  if(tmp.empty() || (tmp.size() > 1 && tmp[0] == '0')) { flag = false; return 0; }
  reverse(all(tmp));
  int res = 0, p = 1;
  rep(i, tmp.size()) {
    res += (tmp[i]-'0')*p;
    p *= 2;
  }
  return res;
}

string B() {
  string res = "";
  while(idx < (int)str.size() && isdigit(str[idx])) res += str[idx++];
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> enc;
  for(char c : enc) {
    if(isalpha(c)) alpha.push_back(c);
  }
  sort(all(alpha));
  alpha.erase(unique(all(alpha)), alpha.end());
  if(alpha.size() > sign.size()) {
    cout << 0 << endl;
    return 0;
  }

  ans = 0;
  sort(all(sign));
  set<string> st;
  do {
    //cout<<sign<<endl;
    idx = 0;
    str = enc;
    for(char &c : str) {
      if(isalpha(c)) c = sign[alpha.find(c)];
    }
    if(st.count(str)) continue;
    st.insert(str);
    if(Q()) {
      //cout << idx << " " << str << endl;
      ans++;
    }
  } while(next_permutation(all(sign)));
  cout << ans << endl;

  return 0;
}