#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL 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(err || p >= N || gs[p] != '='){
	err = 1;
	return 0;
  }
  ++p;
  int r = E(p);
  if(err || 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(err || 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 = SZ(S);

  set<char> s;

  REP(i,N)
	if(('a' <= S[i] && S[i] <= 'z') || ('A' <= S[i] && S[i] <= 'Z'))
	  s.insert(S[i]);
  if(SZ(s) > 8){
	cout << 0 << endl;
	return 0;
  }

  char cs[9] = "+-*=()01";
  sort(cs, cs+8);

  set<string> ans;
  do{
	string tmp = S;
	int j = 0;
	REP(i,N){
	  char c = tmp[i];
	  if(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')){
		REP(k,N)
		  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 << SZ(ans) << endl;
  //for(auto&&s:ans)cout<<s<<endl;

  return 0;
}