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

char moji[] = "01+-*()=";
string s;
char cset[100];
int idx[100];
int length;
vector<int> perm;
int pos;
bool correct;
string currents;
char get(int i){
	if(i >= length){
		return '\0';
	}
	return currents[i];
}

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


bool Q(){
	int a = E();
	if(get(pos) != '='){
		correct  = false;
		return false;
	}
	pos++;
	int b = E();
	return a == b;
}

int E(){
	int t = T();
	while(get(pos) == '+' || get(pos) == '-'){
		if(get(pos) == '+'){
			pos++;
			t += T();
		}else{
			pos++;
			t -= T();
		}
	}
	return t;
}

int T(){
	int f = F();
	while(get(pos) == '*'){
		pos++;
		f *= F();
	}
	return f;
}

int F(){
	if(get(pos) == '-'){
		pos++;
		return - F();
	}
	if(get(pos) == '('){
		pos++;
		int e = E();
		if(get(pos) != ')'){
			correct = false;
		}
		pos++;
		return e;
	}

	return N();
}

int N(){
	if(get(pos) == '0'){
		pos++;
		return 0;
	}
	if(get(pos) == '1'){
		pos++;
		return B(1);
	}
	correct = false;
	return 0;
}

int B(int cur){
	if(get(pos) == '0'){
		pos++;
		return B(cur * 2);
	}
	if(get(pos) == '1'){
		pos++;
		return B(cur * 2 + 1);
	}
	return cur;
}


int main(){
	cin >> s;
	length = s.size();
	int si = 0;
	for(int i = 0; i < s.size(); i++){
		if(!(('a' <= s[i] && s[i] <= 'z') || ('A' <= s[i] && s[i] <= 'Z'))){
			idx[i] = s[i];
			continue;
		}
		int j;
		for(j = 0; j < si; j++){
			if(cset[j] == s[i]) break;
		}
		if(j == si){
			si++;
			if(si > 8){
				cout << 0 << endl;
				return 0;
			}
			cset[j] = s[i];
		}
		idx[i] = j;
	}
	
	for(int i = 0 ; i < 8; i++){
		perm.push_back(i);	
	}

	set<string> smap;

	do{
		string ns = s;
		for(int i = 0; i < ns.size(); i++){
			if(('a' <= s[i] && s[i] <= 'z') || ('A' <= s[i] && s[i] <= 'Z')){
				ns[i] = moji[perm[idx[i]]];
			}
		}
		smap.insert(ns);
	}while(next_permutation(perm.begin(), perm.end()));

	int ans = 0;
	for(string ss : smap){
		currents = ss;
		pos = 0;
		correct = true;
		if(Q() && correct && pos == ss.size()){
			ans++;
		}
	}
	cout << ans << endl;
}