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

using i64 = int64_t;

bool Q(string s, int idx);
pair<i64, int> E(string s, int idx);
pair<deque<i64>, int> E_(string s, int idx);
pair<i64, int> T(string s, int idx);
pair<i64, int> T_(string s, int idx);
pair<i64, int> F(string s, int idx);
pair<string, int> N(string s, int idx);
pair<string, int> B(string s, int idx);

bool error = false;
string letters = "01+-*()=";

i64 to_i64(string s){
    i64 res = 0;
    for(int i=0;i<s.size();++i){
        res *= 2;
        res += s[i] - '0';
    }
    return res;
}

bool Q(string s, int idx){
    auto p = E(s, idx);
    if(error || s[idx+p.second] != '=')return false;
    auto p2 = E(s, idx+p.second+1);
    if(error || p.first != p2.first || p.second+p2.second+1 != s.size())return false;
    else return true;
}

pair<i64, int> E(string s, int idx){
    auto p = T(s, idx);
    if(error){
        return make_pair(-1, -1);
    }
    auto p2 = E_(s, idx+p.second);
    if(error)return make_pair(-1, -1);

    i64 res = p.first;
    for(auto e: p2.first)res += e;
    return make_pair(res, p.second+p2.second);
}

pair<deque<i64>, int> E_(string s, int idx){
    if(idx >= s.size())return make_pair(deque<i64>(), 0);
    if(s[idx] == '+' || s[idx] == '-'){
        auto p = T(s, idx+1);
        if(error)return make_pair(deque<i64>(), -1);
        auto p2 = E_(s, idx+p.second+1);
        if(error)return make_pair(deque<i64>(), -1);
        deque<i64> res = p2.first;
        if(s[idx] == '+'){
            res.push_front(p.first);
            return make_pair(res, p.second+p2.second+1);
        }else{
            res.push_front(-p.first);
            return make_pair(res, p.second+p2.second+1);
        }
    }
    return make_pair(deque<i64>(), 0);
}

pair<i64, int> T(string s, int idx){
    auto p = F(s, idx);
    if(error){
        return make_pair(-1, -1);
    }
    auto p2 = T_(s, idx+p.second);
    if(error)return p2;
    if(p2.second == 0)p2.first = 1;
    return make_pair(p.first*p2.first, p.second+p2.second);
}

pair<i64, int> T_(string s, int idx){
    if(idx >= s.size())return make_pair(0, 0);
    if(s[idx] == '*'){
        auto p = F(s, idx+1);
        if(error)return p;
        auto p2 = T_(s, idx+p.second+1);
        if(error)return p2;
        if(p2.second == 0)p2.first = 1;
        return make_pair(p.first*p2.first, p.second+p2.second+1);
    }
    return make_pair(0, 0);
}

pair<i64, int> F(string s, int idx){
    if(s[idx] == '-'){
        auto p = F(s, idx+1);
        return make_pair(-p.first, p.second+1);
    }
    if(s[idx] == '('){
        auto p = E(s, idx+1);
        if(s[idx+p.second+1] != ')'){
            error = true;
            return make_pair(-1, -1);
        }
        return make_pair(p.first, p.second+2);
    }
    if(s[idx] == '1' || s[idx] == '0'){
        auto p = N(s, idx);
        i64 n = to_i64(p.first);
        return make_pair(n, p.second);
    }
    error = true;
    return make_pair(-1, -1);
}

pair<string, int> N(string s, int idx){
    if(s[idx] == '0')return make_pair("0", 1);
    if(s[idx] == '1'){
        auto p = B(s, idx+1);
        return make_pair("1"+p.first, 1+p.second);
    }
    error = true;
    return make_pair("", -1);
}

pair<string, int> B(string s, int idx){
    if(idx >= s.size())return make_pair("", 0);
    if(s[idx] == '0'){
        auto p = B(s, idx+1);
        return make_pair("0"+p.first, 1+p.second);
    }
    if(s[idx] == '1'){
        auto p = B(s,idx+1);
        return make_pair("1"+p.first, 1+p.second);
    }
    return make_pair("", 0);
}

int main(){
    string s;
    cin >> s;
    set<char> st;
    for(auto c: s){
        bool f = false;
        for(auto cc: letters)
            if(cc == c){
                f = true;
                break;
            }
        if(f)continue;
        st.insert(c);
    }
    if(st.size() > 8){
        cout << 0 << endl;
        return 0;
    }
    vector<char> v;
    for(auto c: st)v.push_back(c);
    while(v.size() < 8)v.push_back('#');
    sort(v.begin(), v.end());
    int ans = 0;
    do{
        string q;
        for(auto c: s){
            bool flag = false;
            for(int i=0;i<v.size();++i){
                if(c == v[i]){
                    q.push_back(letters[i]);
                    flag = true;
                    break;
                }
            }
            if(!flag)q.push_back(c);
        }
        error = false;
        bool f = Q(q, 0);
        if(f)ans++;
        //if(f)cout << q << endl;
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3236