#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// nPr の列挙
template <typename BidirectionalIterator>
inline bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last) {
    reverse(middle, last);
    return next_permutation(first, last);
}

bool Q(const string& s, int& i);
int E(const string& s, int& i, bool& ng);
int T(const string& s, int& i, bool& ng);
int F(const string& s, int& i, bool& ng);
int N(const string& s, int& i, bool& ng);

bool Q(const string& s, int& i) {
    bool ng = false;
    int val = E(s, i, ng);
    if (ng || s[i] != '=') return false;
    ++i; // '='
    ng = false;
    int val2 = E(s, i, ng);
    if (ng || i != s.size()) return false;
    return (val == val2);
}

int E(const string& s, int& i, bool& ng) {
    int val = T(s, i, ng);
    while (s[i] == '+' || s[i] == '-') {
        char op = s[i];
        ++i;
        int val2 = T(s, i, ng);
        if (op == '+') val += val2;
        else val -= val2;
    }
    return val;
}

int T(const string& s, int& i, bool& ng) {
    int val = F(s, i, ng);
    while (s[i] == '*') {
        ++i;
        int val2 = F(s, i, ng);
        val *= val2;
    }
    return val;
}

int F(const string& s, int& i, bool& ng) {
    if (isdigit(s[i])) return N(s, i, ng);
    if (s[i] == '-') {
        ++i;
        return -F(s, i, ng);
    }
    if (s[i] != '(') return (ng = true);
    ++i;
    int val = E(s, i, ng);
    if (s[i] != ')') return (ng = true);
    ++i;
    return val;
}

int N(const string& s, int& i, bool& ng) {
    if (s[i] == '0') {
        ++i;
        return 0;
    }
    if (s[i] == '1') {
        int val = 1;
        ++i;
        while (s[i] == '0' || s[i] == '1') {
            val = val * 2 + (s[i] - '0');
            ++i;
        }
        return val;
    }
    return (ng = true);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    const int n = s.size();
    vector<char> alphabets;
    for (char c : s) if (isalpha(c)) alphabets.push_back(c);
    sort(alphabets.begin(), alphabets.end());
    alphabets.erase(unique(alphabets.begin(), alphabets.end()), alphabets.end());
    const int alphabets_size = alphabets.size();
    string symbols = "()*+-01=";  // ソート済み
    int ans = 0;
    do {
        map<char, char> mp;
        for (int i = 0; i < alphabets_size; ++i) {
            mp[alphabets[i]] = symbols[i];
        }
        int equal_cnt = 0;
        string t;
        t.reserve(100);
        t = s;
        for (int i = 0; i < n; ++i) {
            if (isalpha(s[i])) t[i] = mp[s[i]];
            if (t[i] == '=') ++equal_cnt;
        }
        if (equal_cnt != 1) continue;
        const int equal_pos = t.find('=');
        int i = 0;
        ans += Q(t, i);
    } while (next_partial_permutation(symbols.begin(), symbols.begin() + alphabets_size, symbols.end()));
    cout << ans << endl;
}
