#include <bits/stdc++.h>
using namespace std;

struct Parser {
	using itr = string::const_iterator;
	itr now;
	int ans;
	// E ::= {T{+|-}}+T  T|E+T|E−T
	// T ::= {F*}+F F|T*F
	// F ::= N|{-}+F|(E)
	// N ::= 0|1B
	// B ::= {0|1}* ϵ|0B|1B
	Parser(const string &s) {
		now = s.begin();
		ans = E(now);
		if(*now != '\0') {
			throw "INVALID";
		}
	}
	int E(itr &now) {
		// cerr << "E" << endl;
		// E ::= {T{+|-}}+T  T|E+T|E−T
		int ret = T(now);
		while(*now != '\0') {
			if(*now == '+') {
				next(now, '+');
				ret += T(now);
			} else if(*now == '-') {
				next(now, '-');
				ret -= T(now);
			} else {
				return ret;
			}
		}
		return ret;
	}
	int T(itr &now) {
		// cerr << "T" << endl;
		// T ::= {F*}+F F|T*F
		int ret = F(now);
		while(*now != '\0') {
			if(*now == '*') {
				next(now, '*');
				ret *= T(now);
			} else {
				return ret;
			}
		}
		return ret;
	}
	int F(itr &now) {
		// cerr << "F" << endl;
		// F ::= N|{-}+F|(E)
		if(*now == '-') {
			next(now, '-');
			return -F(now);
		} else if(*now == '(') {
			next(now, '(');
			int ret = E(now);
			next(now, ')');
			return ret;
		} else {
			return N(now);
		}
	}
	int N(itr &now) {
		// cerr << "N" << endl;
		// N ::= 0|1B
		if(*now == '0') {
			next(now, '0');
			return 0;
		} else if(*now == '1') {
			return B(now);
		} else {
			throw "INVALID";
		}
	}
	int B(itr &now) {
		// cerr << "B" << endl;
		// B ::= {0|1}* ϵ|0B|1B
		int ret = 0;
		while(*now != '\0') {
			if(*now == '0' or *now == '1') {
				ret <<= 1;
				ret += (*now) - '0';
				next(now, {'0', '1'});
			} else {
				return ret;
			}
		}
		return ret;
	}
	void next(itr &now, const char expected) {
		vector<char> req = {expected};
		next(now, req);
	}
	void next(itr &now, const vector<char> &expected) {
		for(char c: expected){
			if(*now == c){
				now++;
				return;
			}
		}
		throw "INVALID";
		// デバッグ用
		fprintf(stderr, "Expected: ");
		for(char c: expected) fprintf(stderr, "%c", c);
		fprintf(stderr, "\nGot: %c\n", *now);
		fprintf(stderr, "Rest: ");
		while(*now) fprintf(stderr, "%c", *now++);
	}
};

int main() {
	vector<char> ex = {'0', '1', '+', '-', '*', '(', ')', '='};
	string s; cin >> s;
	map<char, char> mp;
	for(char c : s) {
		bool flg = true;
		for(char cc : ex) {
			if(c == cc) flg = false;
		}
		if(flg) mp[c] = '?';
	}
	if(mp.size() > 8) {
		cout << 0 << '\n';
		return 0;
	}
	int ans = 0;
	sort(ex.begin(), ex.end());
	// reverse(ex.begin(), ex.end());
	do {
		int idx = 0;
		for(auto &e : mp) {
			e.second = ex[idx];
			++idx;
		}
		string str[2];
		int nxt = 0;
		bool valid = true;
		for(char c : s) {
			if(nxt == 2) {
				valid = false;
				break;
			}
			if(mp.count(c)) {
				if(mp[c] == '=') {
					++nxt;
					continue;
				}
				str[nxt].push_back(mp[c]);
			} else {
				if(c == '=') {
					++nxt;
					continue;
				}
				str[nxt].push_back(c);
			}
		}
		if(nxt == 1 and valid) {
			if(str[0].size() == 0) continue;
			if(str[1].size() == 0) continue;
			try {
				// cerr << str[0] << endl;
				// cerr << str[1] << endl;
				Parser parse0(str[0]);
				Parser parse1(str[1]);
				// cerr << parse0.ans << endl;
				// cerr << parse1.ans << endl;
				if(parse0.ans == parse1.ans) {
					++ans;
				}
			}
			catch(...) {
				continue;
			}
		}
	} while(next_permutation(ex.begin(), ex.end()));
	int div = 1;
	for(int i = 1; i <= 8 - mp.size(); ++i) {
		div *= i;
	}
	cout << ans / div << '\n';
	return 0;
}

