#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

char codes[] = "=01()-+*";
int l = 0;

int used[8];
int contain[256];
int ans = 0, cnt = 0;
int counter[8];
char mpc[8];

map<int, int> mp;

int ok = 1;
int cur = 0;
string s;

int expr();

char get(int i) {
    if(i >= l) return '$';
    if(contain[(int)s[i]] == -1) return s[i];
    return mpc[mp[(int) s[i]]];
}

int number() {
    int first = 1; char fc, c;
    int val = 0;
    c = get(cur);
    if(c != '0' && c != '1') {
        ok = 2;
    }

    while(1) {
        c = get(cur);
        if(c != '0' && c != '1') {
            break;
        }
        if(first) fc = c;
        else if(fc == '0') {
            ok = 3;
        }
        val = 2*val + (c - '0');
        first = 0;
        cur ++;
    }
    return val;
}

int factor() {
    char c = get(cur);
    if(c == '-') {
        cur++;
        return -factor();
    } else if(c == '(') {
        cur++; // '('
        if(get(cur) == ')') {
            ok = 4;
        }
        int val = expr();
        if(get(cur) != ')') {
            ok = 5;
            return val;
        }
        cur++; // ')'
        return val;
    }
    return number();
}

int term() {
    char c;
    int res = 1;
    while(1) {
        if(get(cur) == '*') ok = 6;
        res *= factor();
        c = get(cur);
        if(c == '*') {
            cur++; // '*'
        } else {
            break;
        }
    }
    return res;
}

int expr() {
    int res = 0;
    char c = 0, op = '+';
    while(1) {
        if(get(cur) == '+') {
            ok = 7;
        }
        if(op == '+') {
            res += term();
        } else {
            res -= term();
        }
        c = get(cur);
        if(c == '+' || c == '-') {
            op = c;
            cur ++; // "+", "-"
        } else {
            break;
        }
    }
    return res;
}

void check() {
    //for(int i=0; i<l; ++i) {cout << get(i);}cout << endl;
    cur = 0; ok = 1;
    int left = expr();
    if(get(cur) != '=') {
        return;
    }
    cur++; // '='
    int right = expr();
    //cout << "result " << left << " - " << right << " cur " << cur << " ok " << ok<< endl;
    if(cur == l && ok == 1) {
        if(left == right) {
            ans++;
        }
    }
}

// index c
void dfs(int c) {
    if(c == cnt) {
        check();
        return;
    }
    for(int i=0; i<8; ++i) {
        if(used[i]) continue;
        if(i==0) {
            if(counter[c] == 1) {
                used[i] = 1;
                mpc[c] = codes[i];
                dfs(c+1);
                used[i] = 0;
            }
        } else {
            used[i] = 1;
            mpc[c] = codes[i];
            dfs(c+1);
            used[i] = 0;
        }
    }
}

int main() {
    cin >> s;
    l = s.length();
    for(int i=0; i<8; ++i) {
        contain[(int) codes[i]] = -1;
    }
    for(int i=0; i<l; ++i) {
        int v = (int) s[i];
        if(contain[v] == -1) continue;
        if(contain[v] == 0) {
            contain[v] = 1;
            mp[v] = cnt++;
            counter[mp[v]] = 1;
        } else {
            counter[mp[v]] += 1;
        }
    }
    if(cnt > 8) {
        cout << 0 << endl;
    } else {
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}