#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

typedef string::const_iterator State;
int ans;
string s;


ll exp(State &begin);



ll bin(State &begin){
	ll ret=0;
	
	while(isdigit(*begin)){
		ret*=2;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}


ll number(State &begin){
	if(*begin=='0'){
		begin++;
		if(isdigit(*begin))throw "number error1";
		else return 0;
	}
	else if(*begin=='1'){
		return bin(begin);
	}else throw "number error2";
	
	assert(1);
	return -1;
}


ll factor(State &begin){
	if( isdigit(*begin) )return number(begin);
	else if(*begin=='-'){
		begin++;
		if(isdigit(*begin)||*begin=='('||*begin=='-') return -1*factor(begin);
		else throw "factor error1";
	}else if(*begin=='('){
		begin++;
		ll ret = exp(begin);
		if(*begin!=')')throw "factor error2";
		begin++;
		return ret;
	}
	else throw "factor error3";
	assert(1);
	return -1;
}


ll term(State &begin){
	ll ret = factor(begin);
	
	if(*begin=='+'||*begin=='-'||*begin=='$'||*begin==')'){
		return ret;
	}
	else if(*begin=='*'){
		begin++;
		return ret*term(begin);
	}
	else throw "term error";
	
	assert(1);
	return -1;
	
}


ll exp(State &begin){
	ll ret = term(begin);
	
	while(1){
		if(*begin=='+'){
			begin++;
			ret+=term(begin);
		}else if(*begin=='-'){
			begin++;
			ret-=term(begin);
		}else if(*begin=='$'||*begin==')'){
			return ret;
		}else throw "exp error";
	}
	
	assert(1);
	return -1;
}


bool isValid(string tmp){
	int eqc=0;
	rep(i,tmp.size())if(tmp[i]=='=')eqc++;
	if(eqc!=1)return false;
	
	string str[2]={};
	bool f=false;
	rep(i,tmp.size()){
		if(tmp[i]=='=')f=true;
		else if(f)str[1]+=tmp[i];
		else str[0]+=tmp[i];
	}
	if(str[0].size()==0||str[1].size()==0)return false;
	
	State b[2];
	ll res[2];
	try{
		rep(i,2){
			str[i] +='$';
			b[i] = str[i].begin();
			res[i] = exp(b[i]);
		}
	}catch(char const* e){
		return false;
	}
	if(res[0]==res[1] && *b[0]=='$'&&*b[1]=='$'){
		return true;
	}else return false;
}

void dfs(string tmp,vector<bool> used){
	char alp='!';
	int pos=-1;
	rep(i,tmp.size()){
		if(isalpha(tmp[i]))alp=tmp[i],pos=i;
	}
	if(pos==-1){ if(isValid(tmp))ans++; return; }
	
	assert(alp!='!');
	string symbols = "01+-*()=";
	rep(i,symbols.size()){
		if(used[i])continue;
		used[i]=true;
		string ntmp = tmp;
		rep(j,ntmp.size()){
			if(ntmp[j]==alp) ntmp[j] = symbols[i];
		}
		dfs(ntmp,used);
		used[i]=false;
	}
}


int main(){
	cin>>s;
	set<char> st;
	vector<char> vs;
	
	rep(i,s.size())st.insert(s[i]);
	for(auto &e:st)vs.pb(e);
	
	int count=0;
	rep(i,vs.size())if(isalpha(vs[i]))count++;
	if(count>8){
		cout<<0<<endl;
		return 0;
	}
	
	ans=0;
	vector<bool> used(8,false);
	dfs(s,used);
	cout<<ans<<endl;
}