#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int parse_formula(int &p, string &s);
int parse_term(int &p, string &s);
int parse_factor(int &p, string &s);
int parse_number(int &p, string &s);

int parse_formula(int &p, string &s){
    int n = s.length();
    if(p>=n or s[p]==')'){
        throw exception();
    }
    int res = parse_term(p, s);
    while(p<n and (s[p]=='+' or s[p]=='-')){
        int sign = (s[p]=='+')? 1: -1;
        res += sign*parse_term(++p, s);
    }
    if(p>=n or s[p]!=')'){
        throw exception();
    }
    p++;
    return res;
}
int parse_term(int &p, string &s){
    int n = s.length();
    int res = 1;
    while(1){
        res *= parse_factor(p, s);
        if(p>=n or s[p]==')' or s[p]!='*') break;
        p++;
    }
    return res;
}
int parse_factor(int &p, string &s){
    int n = s.length();
    int sign = 1;
    while(p<n and s[p]=='-'){
        sign *= -1;
        p++;
    }
    if(p>=n or !(s[p]=='(' or s[p]=='0' or s[p]=='1')){
        throw exception();
    }
    if(s[p]=='('){
        return sign * parse_formula(++p, s);
    }else{
        return sign * parse_number(p, s);
    }
}
int parse_number(int &p, string &s){
    int n = s.length();
    int res = 0;
    if(p>=n or !(s[p]=='0' or s[p]=='1')){
        throw exception();
    }
    bool leading_zero = s[p]=='0';
    int firstp = p;
    while(p<n and (s[p]=='0' or s[p]=='1')){
        res *= 2;
        res += s[p]-'0';
        p++;
    }
    if(leading_zero and p-firstp > 1){
        throw exception();
    }
    return res;
}

const string alphabet = "01+-*()=";

int main(){
    string s;
    cin >> s;
    vector<char> assign;
    for(char c: s){
        if(('a'<=c and c<='z') or ('A'<=c and c<='Z')){
            assign.push_back(c);
        }
    }
    sort(assign.begin(), assign.end());
    assign.erase(unique(assign.begin(), assign.end()), assign.end());
    while(assign.size() < alphabet.length()){
        assign.push_back('~');
    }
    int ans = 0;
    do{
        string t = s;
        for(int i=0; i<8; i++){
            for(int j=0; j<(int)t.length(); j++){
                if(t[j] == assign[i]){
                    t[j] = alphabet[i];
                }
            }
        }
        int poseq = -1;
        for(int i=0; i<(int)t.length(); i++){
            if(t[i] == '='){
                if(poseq == -1) poseq = i;
                else if(poseq > 0) poseq = -2;
            }
        }
        if(poseq < 0) continue;
        t[poseq] = ')';
        t.push_back(')');
        try{
            int p = 0;
            int ret1 = parse_formula(p, t);
            if(p != poseq+1) continue;
            int ret2 = parse_formula(p, t);
            if(p != (int)t.length()) continue;
            if(ret1 == ret2) ans++;
        }catch(exception){
            continue;
        }
    }while(next_permutation(assign.begin(), assign.end()));
    cout << ans << endl;
    return 0;
}

