#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++ i)
using namespace std;

void Q();
int E();
int T();
int F();
int N();
int B();

int m;
string s;
size_t cur;
bool failed;

//Q::=E=E
void Q(){
	cur = 0,failed = 0;
	m = s.size();
	int l = E();
	if(s[cur]!='=') failed = 1;
	cur++;
	int r = E();
	if(cur != m or l != r) failed = 1;
}

// E::=T|E+T|E???T
int E(){
	int res = T();

	while(cur < m and s[cur] == '+' or s[cur] == '-'){
		char op = s[cur];
		cur++;
		const int arg = T();
		if(op == '+')
			res += arg;
		else
			res -= arg;
	}

	return res;
}

// T::=F|T???F

int T(){
	int res = F();

	while(cur < m and s[cur] == '*'){
		cur++;
		const int arg = F();
		res *= arg;
	}
	
	return res;

}

// F::=N|???F|(E)
int F(){
	if(cur < m and isdigit(s[cur])){
		return N();
	}else if(cur < m and s[cur]=='-'){
		cur++;
		return -F();
	}else if(cur < m and s[cur]=='('){
		cur++;
		const int res = E();
		if(s[cur]!=')') failed = true;
		cur++;
		return res;
	}else{
		failed = true;
		return 0;
	}
}

// N::=0|1B
int N(){
	if(cur < m and s[cur]=='0'){
		cur++;
		return 0;
	}else if(cur < m and s[cur]=='1'){
		cur++;
		return B();
	}else{
		failed = true;
		return 0;
	}
}

// B::=??|0B|1B
int B(){
	int res = 1;
	while(cur < m and isdigit(s[cur])){
		res = 2 * res + (s[cur] - '0');
		cur++;
	}
	//cerr << res << endl;
	return res;
}

char letter[8] = {'0','1','+','-','*','(',')','='};


int main(void){
	string t;
	cin >> t;

	const int n = t.size();
	vector<char> ary;
	rep(i,n) if(isalpha(t[i])) ary.push_back(t[i]);

	sort(begin(ary),end(ary));
	ary.erase(unique(begin(ary),end(ary)),end(ary));

	const int l = ary.size();

	if(l > 8){
		cout << 0 << endl;
		return 0;
	}

	set<string> eq;

	sort(letter,letter+8);
	do{
		string nt = t;
		rep(i,n){
			if(isalpha(nt[i])){
				rep(j,l) if(nt[i] == ary[j]) nt[i] = letter[j];
			}
		}
		eq.insert(nt);
	}while(next_permutation(letter,letter+8));

	int ans = 0;
	for(auto &it:eq){
		//cerr << it << endl;
		s = it;
		Q();
		ans += (failed == 0);
	}

	cout << ans << endl;
	return 0;
}