#include <iostream>
#include <string>
#include <cstdlib>
#include <map>
#include <cctype>
#include <vector>
using namespace std;

typedef long long LL;

const string charset = "01+-*()=";
string input;
int sz;
int ans;
map<char,int> mp;
vector<char> tbl;
const char *p;

LL expr();
LL term();
LL factor();

LL expr(){
	LL x = term();
	while(1){
		if(*p == '+'){
			++p;
			LL y = term();
			x += y;
		}
		else if(*p == '-'){
			++p;
			LL y = term();
			x -= y;
		}
		else{ break; }
	}
	return x;
}

LL term(){
	LL x = factor();
	while(*p == '*'){
		++p;
		LL y = factor();
		x *= y;
	}
	return x;
}

LL factor(){
	if(*p == '-'){
		++p;
		LL x = factor();
		return -x;
	}
	if(*p == '('){
		++p;
		LL x = expr();
		if(*p != ')'){ throw 1; }
		++p;
		return x;
	}
	if(*p == '0'){
		++p;
		return 0;
	}
	if(*p == '1'){
		char *endp;
		LL x = strtoll(p, &endp, 2);
		p = endp;
		return x;
	}
	throw 2;
}

void check() try{
	string e;
	for(char c : input){
		if(isalpha(c)){
			e += tbl[mp[c]];
		}
		else{
			e += c;
		}
	}
	p = e.c_str();
	
	LL lt = expr();
	if(*p == '='){
		++p;
		LL rt = expr();
		if(!*p && lt == rt){
			++ans;
		}
	}
}
catch(...){}

void dfs(int i, int u){
	if(i == sz){
		check();
	}
	else{
		for(int j = 0; j < 8; ++j){
			if(!(u >> j & 1)){
				tbl[i] = charset[j];
				dfs(i + 1, u | 1 << j);
			}
		}
	}
}

int main(){
	cin >> input;
	for(char c : input){
		if(isalpha(c)){
			mp.emplace(c, mp.size());
		}
	}
	sz = mp.size();
	if(sz <= 8){
		tbl.assign(sz, 0);
		dfs(0, 0);
	}

	cout << ans << endl;
}