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

char *s;
bool error;

bool equation();
int64_t expr();
int64_t mul();
int64_t unary();
int64_t num();

bool consume(char c){
    if(*s != c) return false;
    ++s;
    return true;
}

bool equation(){
    error = false;
    int64_t lhs, rhs;
    lhs = expr();
    if(error || !consume('=')) return false;
    rhs = expr();
    if(error || *s != '\0') return false;
    return lhs == rhs;
}

int64_t expr(){
    if(error) return 0;
    int64_t value = mul();
    while(*s == '+' || *s == '-'){
        if(error) return 0;
        if(consume('+')) value += mul();
        else if(consume('-')) value -= mul();
    }
    return value;
}

int64_t mul(){
    if(error) return 0;
    int64_t value = unary();
    while(consume('*')){
        if(error) return 0;
        value *= unary();
    }
    return value;
}

int64_t unary(){
    if(error) return 0;
    int64_t value;
    if(consume('-')) return -unary();
    else if(consume('(')){
        value = expr();
        if(!consume(')')) error = true;
        return value;
    }
    else return num();
}

int64_t num(){
    if(error) return 0;
    int64_t value = 0;
    switch(*s){
    case '0':
        ++s;
        return 0;
    case '1':
        while(*s == '0' || *s == '1'){
            value = value * 2 + (*s - '0');
            ++s;
        }
        return value;
    default:
        error = true;
        return 0;
    }
}

int main(){
    char code[32], *ss = new char[32];
    map<char, int> decl;
    int cnt = 0;
    scanf("%s", code);
    for(int i=0;i < 32 && code[i] != '\0';++i){
        if('A' <= code[i] && code[i] <= 'Z' || 'a' <= code[i] && code[i] <= 'z'){
            if(decl.count(code[i]) == 0) decl[code[i]] = cnt++;
        }
    }

    if(cnt > 8){
        printf("0\n");
        return 0;
    }

    int ptn[] = {0, 1, 2, 3, 4, 5, 6, 7};
    int64_t ans = 0;
    
    do{
        int i;
        s = ss;
        for(i=0;i < 32 && code[i] != '\0';++i){
            if(decl.count(code[i])) s[i] = "01+-*()="[ptn[decl[code[i]]]];
            else s[i] = code[i];
        }
        for(;i<32;++i) s[i] = '\0';
        if(equation()) ++ans;
    }while(next_permutation(ptn, ptn + 8));

    int64_t fact[9];
    fact[0] = 1;
    for(int i=1;i<=8;++i) fact[i] = i * fact[i-1];
    printf("%" PRId64 "\n", ans / fact[8-cnt]);

    return 0;
}
