#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <cctype>
#include <set>

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a ,b) for(int i = int(a); i < int(b); ++i)
#define REP(i, a) FOR(i, 0, a)
#define RFOR(i, a, b) for(int i = int(b)-1; i >= int(a); --i)
#define RREP(i,a) RFOR(i, 0, a)
#define IN(a, x , b) (a <= x && x <= b)
template<class T> inline void CHMIN(T& a, T& b){if(a<b)a=b;}
template<class T> inline void CHMAX(T& a, T& b){if(a>b)a=b;}

using ll = long long;

template<class T> using V = std::vector<T>;
using namespace std;

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

int n;
bool ok;

using State = string::const_iterator;

ll E(State& it, const State& end);
ll T(State& it, const State& end);
ll F(State& it, const State& end);
ll N(State& it, const State& end);

ll E(State& it, const State& end) {
  if(it >= end) {
    ok = false;
    return 0;
  }

  ll res = T(it, end);
  while(it < end) {
    if(*it == '+') {
      ++it;
      res += T(it, end);
    }
    else if(*it == '-') {
      ++it;
      res -= T(it, end);
    }
    else {
      break;
    }
  }
  return res;
}

ll T(State& it, const State& end) {
  if(it >= end) {
    ok = false;
    return 0;
  }

  ll res = F(it, end);
  while(it < end) {
    if(*it == '*') {
      ++it;
      res *= F(it, end);
    }
    else {
      break;
    }
  }
  return res;
}

ll F(State& it, const State& end) {
  if(it >= end) {
    ok = false;
    return 0;
  }

  if(*it == '0' || *it == '1') {
    return N(it, end);
  }
  else if(*it == '-') {
    ++it;
    return -F(it, end);
  }
  else if(*it == '(') {
    ++it;
    ll res = E(it, end);
    if(it >= end || *it != ')') {
      ok = false;
      return 0;
    }
    ++it;
    return res;
  }
  else {
    ok = false;
    return 0;
  }
}

ll N(State& it, const State& end) {
  if(it >= end) {
    ok = false;
    return 0;
  }
  if(*it == '0' && it + 1 < end && (*(it + 1) == '0' || *(it + 1) == '1')) {
    ok = false;
    return 0;
  }

  ll res = 0;
  while(it < end) {
    if(*it == '0') {
      ++it;
      res = res * 2;
    }
    else if(*it == '1') {
      ++it;
      res = res * 2 + 1;
    }
    else {
      break;
    }
  }
  return res;
}

bool isValid(const string& s) {
  if(s[0] == '=' || s[n-1] == '=') return false;
  int eqpos = -1;
  REP(i, n) {
    if(s[i] == '=') {
      if(eqpos == -1) {
        eqpos = i;
      }
      else {
        return false;
      }
    }
  }
  if(eqpos == -1) return false;

  string left = s.substr(0, eqpos);
  string right = s.substr(eqpos + 1);
  ok = true;

  ll leftval;
  {
    auto start = s.cbegin();
    auto end = s.cbegin() + eqpos;
    leftval = E(start, end);
    if(!ok || start != end) return false;
  }
  ll rightval;
  {
    auto start = s.cbegin() + eqpos + 1;
    auto end = s.cend();
    rightval = E(start, end);
    if(!ok || start != end) return false;
  }
  return leftval == rightval;
}

int main(){
  string s;
  cin >> s;
  n = s.size();

  V<int> mapto(256, -1);
  int sz = 0;
  {
    map<char, char> mp;
    REP(i, n) {
      if(isalpha(s[i])) mp[s[i]];
    }
    if(mp.size() > ops.size()) {
      cout << 0 << '\n';
      return 0;
    }
    for(auto& p : mp) {
      p.second = sz++;
      mapto[p.first] = p.second;
    }
  }
  sort(ALL(ops));
  V<int> o(ops.size(), 0);
  REP(i, sz) o[i] = 1;
  reverse(ALL(o));

  int ans = 0;
  do{
    string ops2;
    REP(i, o.size()) if(o[i]) ops2 += ops[i];
    do{
      string s2(s);
      REP(i, n) {
        if(isalpha(s2[i])) s2[i] = ops2[mapto[s2[i]]];
      }
      if(isValid(s2)) {
        ++ans;
        //cout << s2 << endl;
      }
    }while(next_permutation(ALL(ops2)));
  }while(next_permutation(ALL(o)));



  cout << ans << '\n';
}

