#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++;
	bool prod = false;

	while (++state != end) {
		if (m[*state] == '+' || m[*state] == '-') {
			if (paren > 0)continue;
			if (prod) {
				prod = false;
				continue;
			}
			prod = false;
			if (!isT(str, m, tmp, state)) {
				return false;
			}
			tmp = state + 1;
		}
		else if (m[*state] == '(') {
			prod = false;
			paren++;
		}
		else if (m[*state] == ')') {
			prod = false;
			paren--;
		}
		else if (m[*state] == '*') {
			prod = true;
		}
		else {
			prod = false;
		}
	}
	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;

	// +?????§??????
	rep(i, str.size()) {
		if (m[str[i]] == '+') {
			if (i == 0 || !(m[str[i - 1]] == '0' || m[str[i - 1]] == '1' || m[str[i - 1]] == ')'))return false;
		}
	}

	// --,+-???????????????
	string tmp = "";
	vc charr(str.size());
	rep(i, str.size()) {
		charr[i] = str[i];
	}
	rep(i, charr.size() - 1) {
		if (m[charr[i]] == '-'&&m[charr[i + 1]] == '-') {
			charr[i + 1] = '+';
		}
		else if (m[charr[i]] == '+'&&m[charr[i + 1]] == '-') {
			charr[i + 1] = '-';
		}
		else {
			if (tmp.size() == 0 && charr[i] == '+') {
				continue;
			}
			else if (tmp.size() > 0 && (m[tmp[tmp.size() - 1]] == '=' || m[tmp[tmp.size() - 1]] == '(' || m[tmp[tmp.size() - 1]] == '*') && charr[i] == '+') {
				continue;
			}
			tmp += charr[i];
		}
	}
	tmp += charr[charr.size() - 1];
	//cout << tmp << endl;

	rep(i, tmp.size()) {
		if (m[tmp[i]] == '=') {
			index = i;
			break;
		}
	}

	State state = tmp.begin();
	if (!isE(tmp, m, state, state + index))return false;
	state++;
	if (!isE(tmp, m, state, tmp.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;
	bool prod = false;

	while (++state != end) {
		if (m[*state] == '+') {
			if (paren > 0)continue;
			if (prod) {
				prod = false;
				continue;
			}
			if (plus) {
				val += T(str, m, tmp, state);
			}
			else {
				val -= T(str, m, tmp, state);
			}
			prod = false;
			plus = true;
			tmp = state + 1;
			//state++;
		}
		else if (m[*state] == '-') {
			if (paren > 0)continue;
			if (prod) {
				prod = false;
				continue;
			}
			prod = false;
			if (plus) {
				val += T(str, m, tmp, state);
			}
			else {
				val -= T(str, m, tmp, state);
			}
			plus = false;
			tmp = state + 1;
			//state++;
		}
		else if (m[*state] == '(') {
			prod = false;
			paren++;
		}
		else if (m[*state] == ')') {
			prod = false;
			paren--;
		}
		else if (m[*state] == '*') {
			prod = true;
		}
		else {
			prod = false;
		}
	}
	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) {
	// --,+-???????????????
	string tmp = "";
	vc charr(str.size());
	rep(i, str.size()) {
		charr[i] = str[i];
	}
	rep(i, charr.size() - 1) {
		if (m[charr[i]] == '-'&&m[charr[i + 1]] == '-') {
			charr[i + 1] = '+';
		}
		else if (m[charr[i]] == '+'&&m[charr[i + 1]] == '-') {
			charr[i + 1] = '-';
		}
		else {
			if (tmp.size() == 0 && charr[i] == '+') {
				continue;
			}
			else if (tmp.size() > 0 && m[tmp[tmp.size() - 1]] == '=' && charr[i] == '+') {
				continue;
			}
			tmp += charr[i];
		}
	}
	tmp += charr[charr.size() - 1];

	int index = -1;
	rep(i, tmp.size()) {
		if (m[tmp[i]] == '=') {
			index = i;
			break;
		}
	}
	int lhs = 0, rhs = 0;
	State state = tmp.begin();
	lhs = E(tmp, m, state, state + index);
	state++;
	rhs = E(tmp, m, state, tmp.end());

	//cout << lhs << " " << rhs << endl;

	return lhs == rhs;
}

int main(void) {
	/*
	ofstream ofs("output.txt");
	cout.rdbuf(ofs.rdbuf());
	*/
	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['='] = '=';
	/*
	string d = "(0)";
	cout << "xo"[isE(d, m, d.begin(), d.end())] << endl;
	//cout << "xo"[isQ("1+11*1-11010=(10110)-10", m)] << endl;
	cout << "xo"[isQ("(--0)=0", m)] << endl;
	cout << "xo"[check("(--0)=0", m)] << endl;
	return 0;
	//*/
	int count = 0;
	int ans = 0;
	do {
		rep(i, ch.size()) {
			m[ch[i]] = simbol[perm[i]];
		}
		if (isQ(str, m)) {
			/*
			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;
			//*/
			if (check(str, m)) {
				//cout << "=======================" << endl;
				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;
}

Measured memory_bytes: 3200