#include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;


string str;
bool Q(size_t &i);
ll E(size_t &i);
ll T(size_t &i);
ll F(size_t &i);
ll N(size_t &i);

bool Q(size_t &i){
	ll lhs = 1, rhs = 0;
	try{
		lhs = E(i);
		if(i == str.size() || str[i] != '=')return false;
		rhs = E(++i);
	} catch(int){
		return false;
	}
//	cerr << lhs << " " << rhs << endl;
	if(i < str.size())return false;
	if(lhs == rhs)return true;
	else return false;
}

ll E(size_t &i){
	auto lhs = T(i);
//	cerr << lhs << ";";
	while(i < str.size()){
		auto ope = str[i];
		if(ope != '+' && ope != '-')return lhs;
		auto rhs = T(++i);
		if(ope == '+')lhs = lhs + rhs;
		else if(ope == '-')lhs = lhs - rhs;
		else return lhs;
	}
	return lhs;
}

ll T(size_t &i){
	ll lhs = F(i);
	while(i < str.size() && str[i] == '*'){
		auto rhs = F(++i);
		lhs = lhs * rhs;
	}
	return lhs;
}

ll F(size_t &i){
	if(i >= str.size())throw -1;
	if(str[i] == '('){
		ll ret = E(++i);
		if(i >= str.size() || str[i] != ')')throw -1;
		i++;
		return ret;
	}
	if(str[i] == '-'){
		auto ret = F(++i);
		return -ret;
	}
	return N(i);
}

ll N(size_t &i){
	if(str[i] == '0'){i++; return 0;}
	if(str[i] != '1')throw -1;
	ll ret = 1;
	i++;
	for(;i < str.size() && isdigit(str[i]);i++){
		ret <<= 1;
		if(str[i] == '1')ret += 1;
	}
	return ret;
}

bool next_combination(const vector<int>::iterator begin, const vector<int>::iterator end, const int r){
	if(r == 0)return false;
	auto target = upper_bound(begin, begin+r, *(end-1));
	if(target != begin)--target;
	if(target == begin && *target >= *(end-1)){
		rotate(begin, begin+r, end);
		return false;
	}
//	cerr << "hi";
	auto next = upper_bound(begin+r, end, *target);
	swap(*target, *next);
	++target; ++next;
	vector<int> arr;
	for(auto itr = next; itr != end; ++itr)arr.push_back(*itr);
	for(auto itr = target; itr != begin+r; ++itr)arr.push_back(*itr);
	size_t idx = 0;
	for(auto itr = target; itr != end && idx < arr.size(); ++itr){
		if(itr == begin+r && next != end)itr = next;
		swap(arr[idx], *itr);
		idx++;
	}
	return true;
}

signed main(){
	string raw;
	cin >> raw;
	map<char, int> m;
	int cnt = 0;
	for(auto e : raw){
		if(isalpha(e) && m.find(e) == m.end()){
			m[e] = cnt++;
		}
	}
//	cerr << cnt << endl;
	if(cnt > 8){
		cout << 0 << endl;
		return 0;
	}
	vector<char> c = {'0', '1', '+', '-', '*', '(', ')', '='};
	vector<int> idx={0,1,2,3,4,5,6,7};
	int ans = 0;
	do{	
		do{
			size_t i = 0;
			for(auto &e : raw){
				if(m.find(e) != m.end()){
					str.push_back(c[idx[m[e]]]);
				}
				else{
					str.push_back(e);
				}
			}
//			cerr << str << endl;
			if(Q(i)){
				ans++;
			}
			str.resize(0);
		}while(next_permutation(idx.begin(), idx.begin()+cnt));
	}while(cnt != 8  && next_combination(ALL(idx),cnt));
	cout << ans << endl;

	return 0;
}


