#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint readE();

string s, t;
vector<char> vec;

llint pos;
bool err;

llint readN()
{
	if(t[pos] == '0'){
		pos++;
		return 0;
	}
	if(t[pos] != '1'){
		err = true;
		return 0;
	}
	llint ret = 0;
	while(t[pos] == '0' || t[pos] == '1'){
		ret *= 2;
		ret += t[pos] - '0';
		pos++;
	}
	return ret;
}

llint readF()
{
	if(t[pos] == '-'){
		pos++;
		return -readF();
	}
	else if(t[pos] == '('){
		pos++;
		int ret = readE();
		if(t[pos] == ')'){
			pos++;
			return ret;
		}
		err = true;
		return 0;
	}
	else if(t[pos] == '0' || t[pos] == '1') return readN();
	
	err = true;
	return 0;
}

llint readT()
{
	llint ret = 1;
	while(1){
		ret *= readF();
		if(t[pos] == '*') pos++;
		else return ret;
	}
}

llint readE()
{
	llint ret = 0, sgn = 1;
	while(1){
		ret += sgn * readT();
		if(t[pos] == '+'){
			pos++;
			sgn = 1;
		}
		else if(t[pos] == '-'){
			pos++;
			sgn = -1;
		}
		else return ret;
	}
}

bool readQ()
{
	llint l = readE();
	if(t[pos] != '='){
		err = true;
		return false;
	}
	pos++;
	llint r = readE();
	if(t[pos] != '#'){
		err = true;
		return false;
	}
	return l == r;
}

int main(void)
{
	cin >> s;
	s += "#";
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'A' && s[i] <= 'Z' || s[i] >= 'a' && s[i] <= 'z') vec.push_back(s[i]);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	int C = vec.size();
	if(C > 8){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'A' && s[i] <= 'Z' || s[i] >= 'a' && s[i] <= 'z'){
			s[i] = (int)(lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin()) + 'a';
		}
	}
	
	llint ans = 0;
	llint perm[8];
	for(int i = 0; i < 8; i++) perm[i] = i;
	const char c[] = {'0', '1', '+', '-', '*', '=', '(', ')'};
	
	t = s;
	do{
		for(int i = 0; i < s.size(); i++){
			if(s[i] >= 'a' && s[i] <= 'z') t[i] = c[perm[s[i]-'a']];
			else t[i] = s[i];
		}
		pos = 0;
		err = false;
		if(readQ() && !err) ans++;
	}while(next_permutation(perm, perm+8));
	
	llint div = 1;
	for(int i = 1; i <= 8-C; i++) div *= i;
	cout << ans / div << endl;
	
	return 0;
}
