#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;

bool flag;

int B(string &s, int &n){
	int ret = 0;
	while(1){
		if( !isdigit(s[n]) ){ break; }
		else if( s[n] == '0' ){ n++; ret<<=1; }
		else if( s[n] == '1' ){ n++; ret<<=1; ret += 1; }
	}
	//cout << "B " << ret << "  " << flag << endl;
	return ret;
}

int N(string &s, int &n){
	if( !isdigit(s[n]) ){ flag = false; }
	else if( s[n] == '0' ){ n++; return 0; }
	else if( s[n] == '1' ){ return B(s, n); }
	//cout << "flag N" << endl;
	return 0;
}

int E(string &s, int &n, int ret=0, int d=1);
int F(string &s, int &n){
	int ret;
	if( isdigit(s[n]) ){ ret = N(s, n); }
	else if( s[n] == '-' ){ n++; ret = -F(s, n); }
	else if( s[n] == '(' ){
		n++;
		ret = E(s, n);
		if( s[n] == ')' ) n++;
		else flag = false;
	} else {
		//cout << "flag F" << endl;
		flag = false;
	}
	//cout << "F " << ret << "  " << flag << endl;
	return ret;
}

int T(string &s, int &n){
	int ret = F(s,n);
	if( s[n] == '*' ){ n++; ret *= T(s, n); }
	//cout << "T " << ret << "  " << flag << endl;
	return ret;
}

int E(string &s, int &n, int ret, int d){
	ret += T(s,n) * d;
	if( s.size() <= n ){}
	else if( s[n] == '+' ){ n++; ret = E(s, n, ret,  1); }
	else if( s[n] == '-' ){ n++; ret = E(s, n, ret, -1); }
	//cout << "E " << ret << "  " << flag << endl;
	return ret;
}

bool Q(string &s){
	flag = true;
	int n=0;
	int l = E(s,n);
	//cout << "l = " << l << endl;
	if( s[n] == '=' ) n++;
	else return false;
	int r = E(s,n);
	//cout << "r = " << r << endl;
	if( s[n] != '$' ) flag = false;
	return flag && l == r;
}

string ope = "01+-*()=";
int main(){
	set<string> ans;
	string S;
	cin >> S;
	
	vector<char> v;
	for(char c: S){
		if( 'A' <= c && c <= 'Z' ) v.push_back(c);
		if( 'a' <= c && c <= 'z' ) v.push_back(c);
	}
	sort(all(v));
	v.erase( unique(all(v)), v.end() );
	if( v.size() > 8 ){
		cout << 0 << endl;
		return 0;
	}

	sort( all(ope) );
	do{
		char mp[127]={};
		rep(i,v.size()) mp[v[i]] = ope[i];
		string s;
		for(char c: S) s += (mp[c] ? mp[c] : c);
		s += '$';
		//cout << s << endl;
		if( Q(s) ) ans.insert(s);
	}while( next_permutation(all(ope)) );

	//for(auto p: ans) cout << p << endl;
	cout << ans.size() << endl;

	return 0;
}