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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

string S;

int ei(string::iterator &it,int r){
    if(r==0){
        vint lis;
        while(it!=S.end()){
            int x=ei(it,1);
            if(*it!='='||x==INF)return INF;
            lis.pb(x);
            it++;
        }
        if(lis.size()!=2||lis[0]!=lis[1])return INF;
        return 114514;
    }

    if(r==1){
        int ret=ei(it,2);
        if(ret==INF)return INF;
        while(true){
            if(*it=='+'){
                it++;
                int x=ei(it,2);
                if(x==INF)return INF;
                ret+=x;
            }
            else if(*it=='-'){
                it++;
                int x=ei(it,2);
                if(x==INF)return INF;
                ret-=x;
            }
            else break;
        }
        return ret;
    }

    if(r==2){
        int ret=ei(it,3);
        if(ret==INF)return INF;
        while(true){
            if(*it=='*'){
                it++;
                int x=ei(it,3);
                if(x==INF)return INF;
                ret*=x;
            }
            else break;
        }
        return ret;
    }
    if(r==3){
        if(*it=='-'){
            it++;
            int x=ei(it,3);
            if(x==INF)return INF;
            return -x;
        }
        if(*it=='('){
            it++;
            int x=ei(it,1);
            if(*it!=')')return INF;
            it++;
            if(x==INF)return INF;
            return x;
        }
        return ei(it,4);
    }

    if(r==4){
        bool f=*it=='0';
        if(!isdigit(*it))return INF;
        int ret=0;
        int cnt=0;
        while(isdigit(*it)){
            ret=ret*2+*it-'0';
            it++;
            cnt++;
        }
        
        if(f&&cnt!=1)return INF;
        return ret;
    }
}

signed main(){
    string s;cin>>s;

    vector<char>v;
    rep(i,s.size())if(isalpha(s[i]))v.pb(s[i]);
    sort(all(v));v.erase(unique(all(v)),v.end());

    if(v.size()>8){
        cout<<0<<endl;
        return 0;
    }

    string x="+-*()=01";
    sort(all(x));

    int ans=0;


    set<string>st;
    do{
        S=s;
        rep(i,S.size()){
            if(isalpha(S[i])){
                int k=lower_bound(all(v),S[i])-v.begin();
                S[i]=x[k];
            }
        }
        S+="=";
        auto it=S.begin();
        if(ei(it,0)!=INF){
            ans++;
        }
    }while(next_permutation(all(x)));


    rep(i,(int)x.size()-(int)v.size())ans/=i+1;

    cout<<ans<<endl;
    return 0;
}