#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
//*
// ????????????????§?????§£?????¨
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool isB(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return true;
	if (m[*state] == '0' || m[*state] == '1') {
		state++;
		return isB(str, m, state, end);
	}
	else {
		return false;
	}
}

bool isN(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	if (m[*state] == '0') {
		state++;
		if (state == end)return true;
		else return false;
	}
	else if (m[*state] == '1') {
		state++;
		return isB(str, m, state, end);
	}
	else return false;
}

bool isE(string &str, map<char, char> &m, State &state, State &end);

bool isF(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	if (m[*state] == '-') {
		state++;
		return isF(str, m, state, end);
	}
	else if (m[*state] == '(') {
		state++;
		if (state == end)return false;
		end--;
		if (isE(str, m, state, end)) {
			state++;
			return true;
		}
		else {
			state++;
			return false;
		}
	}
	else {
		return isN(str, m, state, end);
	}
}

bool isT(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	State tmp = state;
	int paren = 0;
	if (m[*state] == '(')paren = 1;
	while (++state != end) {
		if (m[*state] == '*') {
			if (paren > 0)continue;
			if (!isF(str, m, tmp, state)) {
				return false;
			}
			tmp = state + 1;
		}
		else if (m[*state] == '(') {
			paren++;
		}
		else if (m[*state] == ')') {
			paren--;
		}
	}
	if (!isF(str, m, tmp, state)) {
		return false;
	}
	return true;
}

bool isE(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	State tmp = state;
	int paren = 0;
	if (m[*state] == '(')paren = 1;
	while (++state != end) {
		if (m[*state] == '+' || m[*state] == '-') {
			if (paren > 0)continue;
			if (!isT(str, m, tmp, state)) {
				return false;
			}
			tmp = state + 1;
		}
		else if (m[*state] == '(') {
			paren++;
		}
		else if (m[*state] == ')') {
			paren--;
		}
	}
	if (!isT(str, m, tmp, state)) {
		return false;
	}
	return true;
}

bool isQ(string &str, map<char, char> &m) {
	int index = -1;
	rep(i, str.size()) {
		if (m[str[i]] == '=') {
			if (index != -1)return false;
			index = i;
		}
	}
	if (index == -1)return false;

	// ??????????????§??????
	int num = 0;
	rep(i, index) {
		if (m[str[i]] == '(')num++;
		else if (m[str[i]] == ')')num--;
		if (num < 0)return false;
	}
	if (num != 0)return false;
	repl(i, index + 1, str.size()) {
		if (m[str[i]] == '(')num++;
		else if (m[str[i]] == ')')num--;
		if (num < 0)return false;
	}
	if (num != 0)return false;

	State state = str.begin();
	if (!isE(str, m, state, state + index))return false;
	state++;
	if (!isE(str, m, state, str.end()))return false;
	return true;
}

int N(string &str, map<char, char> &m, State &state, State &end) {
	int val = 0;
	while (state != end) {
		val <<= 1;
		if (m[*state] == '1') {
			val += 1;
		}
		state++;
	}
	return val;
}

int E(string &str, map<char, char> &m, State &state, State &end);

int F(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	if (m[*state] == '-') {
		state++;
		return -F(str, m, state, end);
	}
	else if (m[*state] == '(') {
		state++;
		if (state == end)return false;
		end--;
		int val = E(str, m, state, end);
		state++;
		return val;
	}
	else {
		return N(str, m, state, end);
	}
}

int T(string &str, map<char, char> &m, State &state, State &end) {
	if (state == end)return false;
	State tmp = state;
	int val = 1;
	int paren = 0;
	if (m[*state] == '(')paren = 1;

	while (++state != end) {
		if (m[*state] == '*') {
			if (paren > 0)continue;
			val *= F(str, m, tmp, state);
			tmp = state + 1;
		}
		else if (m[*state] == '(') {
			paren++;
		}
		else if (m[*state] == ')') {
			paren--;
		}
	}
	val *= F(str, m, tmp, state);
	return val;
}

int E(string &str, map<char, char> &m, State &state, State &end) {
	State tmp = state;
	int val = 0;
	bool plus = true;
	int paren = 0;
	if (m[*state] == '(')paren = 1;

	while (++state != end) {
		if (m[*state] == '+') {
			if (paren > 0)continue;
			if (plus) {
				val += T(str, m, tmp, state);
			}
			else {
				val -= T(str, m, tmp, state);
			}
			plus = true;
			tmp = state + 1;
		}
		else if (m[*state] == '-') {
			if (paren > 0)continue;
			if (plus) {
				val += T(str, m, tmp, state);
			}
			else {
				val -= T(str, m, tmp, state);
			}
			plus = false;
			tmp = state + 1;
		}
		else if (m[*state] == '(') {
			paren++;
		}
		else if (m[*state] == ')') {
			paren--;
		}
	}
	if (plus) {
		val += T(str, m, tmp, state);
	}
	else {
		val -= T(str, m, tmp, state);
	}
	return val;
}

bool check(string &str, map<char, char> &m) {
	int index = -1;
	rep(i, str.size()) {
		if (m[str[i]] == '=') {
			if (index != -1)return false;
			index = i;
		}
	}
	int lhs = 0, rhs = 0;
	State state = str.begin();
	lhs = E(str, m, state, state + index);
	state++;
	rhs = E(str, m, state, str.end());

	return lhs == rhs;
}

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

	vc ch;
	set<char> st;
	for (char c : str) {
		if (c == '0' || c == '1' || c == '+' || c == '-' || c == '*' || c == '(' || c == ')' || c == '=')continue;
		if (st.find(c) == st.end()) {
			st.insert(c);
			ch.push_back(c);
		}
	}
	if (ch.size() > 8) {
		cout << 0 << endl;
		return 0;
	}

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

	vi perm(8);
	rep(i, 8)perm[i] = i;
	map<char, char>m;
	m['0'] = '0';
	m['1'] = '1';
	m['+'] = '+';
	m['-'] = '-';
	m['*'] = '*';
	m['('] = '(';
	m[')'] = ')';
	m['='] = '=';
	/*
	cout << check("10=-0*10", m) << endl;
	string dummy = "(-0)";
	cout << "xo"[isT(dummy, m, dummy.begin(), dummy.end())] << endl;
	return 0;
	//*/
	int count = 0;
	int ans = 0;
	do {
		rep(i, ch.size()) {
			m[ch[i]] = simbol[perm[i]];
		}
		if (isQ(str, m) && check(str, m)) {
			ans++;
		}
		/*
		if (count % 720 == 0) {
			for (char c : str) {
				cout << m[c];
			}
			cout << " : " << "xo"[isQ(str, m) ? 1 : 0] << " ";
			if (isQ(str, m)) {
				cout << "xo"[check(str, m) ? 1 : 0] << " ";
			}
			cout << count << endl;
		}
		count++;
		//*/
	} while (next_permutation(perm.begin(), perm.end()));

	repl(i, 1, 9 - ch.size()) {
		ans /= i;
	}

	cout << ans << endl;

	return 0;
}