#include <bits/stdc++.h>

using namespace std;

bool error = false;
string errorName = "";
int errorIndex = -1;

bool Q(string& s, int& index);
int E(string& s, int& index); 
int T(string& s, int& index);
int F(string& s, int& index);
int N(string& s, int& index);

bool Q(string& s, int& index){
    int l = E(s, index);
    if(error){
        return false;
    }

    if(s[index] != '='){
        errorName = "Qnot=";
        errorIndex = index;
        return false;
    }
    index++;
    int r = E(s, index);
    if(error){
        return false;
    }

    if(s[index] != '#'){
        errorName = "Qend2";
        errorIndex = index;
        return false;
    }

    return (l == r);
}

int E(string& s, int& index){
    int ret = T(s, index);
    if(error){
        return -1;
    }

    while(true){
        if(s[index] == '+'){
            index++;
            int temp = T(s, index);
            if(error){
                return -1;
            }
            ret += temp;
        }
        else if(s[index] == '-'){
            index++;
            int temp = T(s, index);
            if(error){
                return -1;
            }
            ret -= temp;
        }
        else{
            break;
        }
    }

    return ret;
}

int T(string& s, int& index){
    int ret = F(s, index);
    if(error){
        return -1;
    }

    while(true){
        if(s[index] == '*'){
            index++;
            int temp = F(s, index);
            if(error){
                return -1;
            }
            ret *= temp;
        }
        else{
            break;
        }
    }
    
    return ret;
}

int F(string& s, int& index){

    if(s[index] == '-'){
        index++;
        int f = F(s, index);
        if(error){
            return -1;
        }
        return -f;
    }
    else if(s[index] == '('){
        index++;
        int ret = E(s, index);
        if(error){
            return -1;
        }
        if(index == (int)s.size() || s[index] != ')'){
            error = true;
            errorName = "Fnot)";
            errorIndex = index;
            return -1;
        }
        index++;
        return ret;
    }

    int ret = N(s, index);
    if(error){
        return -1;
    }
    return ret;
}

int N(string& s, int& index){

    if(s[index] == '0'){
        index++;
        return 0;
    }
    else if(s[index] == '1'){
        index++;
        int ret = 1;
        while(index != (int)s.size() && isdigit(s[index])){
            ret *= 2;
            ret += s[index] - '0';
            index++;
        }
        return ret;
    }
    else{
        error = true;
        errorName = "Nend2";
        errorIndex = index;
        return -1;
    }
}
int main(){

    string s;
    cin >> s;

    set<char> cSet;
    for(char c: s){
        if(('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')){
            cSet.insert(c);
        }
    }

    vector<char> cList(cSet.begin(), cSet.end());
    int cSize = (int)cList.size();
    if(cSize > 8){
        cout << 0 << endl;;
    }
    else{

        int ans = 0;

        char replaceList[] = {'0', '1', '+', '-', '*', '(', ')', '='};
        vector<int> com(8, 0);
        for(int i = 0; i < cSize; i++){
            com[8 - i - 1] = 1;
        }

        vector<int> order(cSize);
        for(int i = 0; i < cSize; i++){
            order[i] = i;
        }

        do{
            vector<char> useList;
            for(int i = 0; i < 8; i++){
                if(com[i] == 1){
                    useList.push_back(replaceList[i]);
                }
            }

            do{
                string temp = s + '#';
                for(int i = 0; i < cSize; i++){
                    replace(temp.begin(), temp.end(), cList[i], useList[order[i]]);
                }
                int begin = 0;
                error = false;
                errorName = "";
                bool isOk = Q(temp, begin);

                if(isOk){
                    ans++;
                }
                else{
                    if(errorName != "Qnot="){
                        //cout << temp << " " << errorName << " " << errorIndex << endl;
                    }
                }

            }while(next_permutation(order.begin(), order.end()));
        }while(next_permutation(com.begin(), com.end()));

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3216