#include <bits/stdc++.h>
#define ALL(V) (V).begin(),(V).end()
#define ALLR(V) (V).rbegin(),(V).rend()
#define endl '\n'
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;
using TLL = tuple<ll, ll, ll>;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

bool success;
bool Q(const string &S, ll &idx);
ll E(const string &S, ll &idx);
ll T(const string &S, ll &idx);
ll F(const string &S, ll &idx);
ll N(const string &S, ll &idx);
// ll B(const string &S, ll &idx);

bool calc(const string &S) {
    ll idx = 0;
    success = true;
    return Q(S, idx);
}

bool Q(const string &S, ll &idx) {
    ll left = E(S, idx);
    if(!success) return false;
    if(!(idx < S.size() && S[idx] == '=')) return false;
    idx++;
    ll right = E(S, idx);
    return idx == S.size() && success && left == right;
}

ll E(const string &S, ll &idx) {
    ll ret = T(S, idx);
    while(true) {
        if(S.size() <= idx) break;
        if(S[idx] == '+') {
            idx++;
            ll r = T(S, idx);
            ret += r;
        } else if(S[idx] == '-') {
            idx++;
            ll r = T(S, idx);
            ret -= r;
        } else {
            if(!(S[idx] == '=' || S[idx] == ')')) success = false;
            break;
        }
    }
    if(!success) return 0;
    return ret;
}

ll T(const string &S, ll &idx) {
    ll ret = F(S, idx);
    while(true) {
        if(S.size() <= idx) break;
        if(S[idx] == '*') {
            idx++;
            ll r = F(S, idx);
            ret *= r;
        } else {
            if(!(S[idx] == '+' || S[idx] == '-' || S[idx] == '=' || S[idx] == ')')) success = false;
            break;
        }
    }
    if(!success) return 0;
    return ret;
}

bool is_digit(char c) { return c == '0' || c == '1'; };

ll F(const string &S, ll &idx) {
    if(S.size() <= idx) {
        success = false;
        return 0;
    }
    if(is_digit(S[idx])) return N(S, idx);
    if(S[idx] == '-') {
        idx++;
        return -F(S, idx);
    }
    if(S[idx] == '(') {
        idx++;
        ll ret = E(S, idx);
        if(!(idx < S.size() && S[idx] == ')')) success = false;
        else idx++;
        return ret;
    }
    success = false;
    return 0;
}

ll N(const string &S, ll &idx) {
    static auto check = [](char c) {
        return (c == '=' ||
                c == '+' ||
                c == '-' ||
                c == '*' ||
                c == ')');
    };

    if(!is_digit(S[idx])) {
        success = false;
        return 0;
    }
    if(S[idx] == '0') {
        idx++;
        return 0;
    }
    ll ret = S[idx] - '0';
    idx++;
    while(true) {
        if(idx == S.size()) break;
        if(is_digit(S[idx])) {
            ret = ret * 2 + (S[idx] - '0');
            idx++;
        } else {
            if(!check(S[idx])) success = false;
            break;
        }
    }
    return ret;
}

ll alp2idx(char c) {
    if('a' <= c && c <= 'z') return c - 'a';
    if('A' <= c && c <= 'Z') return c - 'A' + 26;
    assert(false);
}

int main() {
    string S;
    cin >> S;
    ll cnt = 0;
    V<char> alp_lis;
    for(char c : S) {
        if('a' <= c && c <= 'z') alp_lis.push_back(c);
        if('A' <= c && c <= 'Z') alp_lis.push_back(c);
    }
    {
        sort(ALL(alp_lis));
        auto ite = unique(ALL(alp_lis));
        alp_lis.erase(ite, alp_lis.end());
    }
    V<char> op_lis = { '0', '1', '+', '-', '*', '=', '(', ')' };
    if(op_lis.size() < alp_lis.size()) {
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(op_lis));
    ll chr_idx[52] = {};
    ll ans = 0;
    for(ll i = 0; i < alp_lis.size(); i++) chr_idx[alp2idx(alp_lis[i])] = i;
    do {
        auto T = S;
        for(char &c : T) {
            if(!(('a' <= c && c <= 'z') ||
                 ('A' <= c && c <= 'Z'))) continue;
            ll idx = chr_idx[alp2idx(c)];
            c = op_lis[idx];
        }
        auto tmp = calc(T);
        ans += tmp;
        // if(tmp) cout << T << endl;
    } while(next_permutation(ALL(op_lis)));
    for(ll i = 1; i < op_lis.size() - alp_lis.size(); i++) ans /= (i + 1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3204