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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX

string s,t;
int n;
vector<char> cs,match;
string cand="01+-*()=";
bool used[10];
int res=0;

int calc_e(int& l,int term);

int calc_f(int& l,int term){
  if(l>=term)return -INF;

  if(isdigit(t[l])){
    int v=0;
    if(t[l]=='0'&&l+1<term&&isdigit(t[l+1]))return -INF;
    while(l<term&&isdigit(t[l])){
      v<<=1;
      v+=t[l]-'0';
      l++;
    }
    return v;
  }else if(t[l]=='-'){
    l++;
    int v=calc_f(l,term);
    if(v==-INF)return -INF;
    return -v;
  }else if(t[l]=='('){
    l++;
    int v=calc_e(l,term);
    if(v==-INF||t[l]!=')')return -INF;
    l++;
    return v;
  }else{
    return -INF;
  }
}

int calc_t(int& l,int term){
  if(l>=term)return -INF;
  int v=calc_f(l,term);
  if(v==-INF||l>term)return -INF;
  while(l<term&&t[l]=='*'){
    l++;
    int nv=calc_f(l,term);
    if(nv==-INF)return -INF;
    v*=nv;
  }
  return v;
}

int calc_e(int& l,int term){
  if(l>=term)return -INF;
  int v=calc_t(l,term);
  if(v==-INF||l>term)return -INF;
  while(l<term&&(t[l]=='+'||t[l]=='-')){
    if(t[l]=='+'){
      l++;
      int nv=calc_t(l,term);
      if(nv==-INF)return -INF;
      v+=nv;
    }else if(t[l]=='-'){
      l++;
      int nv=calc_t(l,term);
      if(nv==-INF)return -INF;
      v-=nv;
    }
  }
  return v;
}

void dfs(int i){
  if(i==cs.size()){
    t="";
    rep(j,s.size()){
      if(exist(cand,s[j])){
        t+=s[j];
        continue;
      }
      rep(k,cs.size()){
        if(s[j]==cs[k]){
          t+=match[k];
          break;
        }
      }
    }
    int cnt=0;
    rep(j,t.size()){
      if(t[j]=='=')cnt++;
    }
    if(cnt!=1)return ;
    rep(j,t.size()){
      if(t[j]=='='){
        int l=0,r=j+1;
        int cntc=0;
        bool ok=true;
        repl(k,l,j){
          if(t[k]=='(')cntc++;
          if(t[k]==')')cntc--;
          if(cntc<0)ok=false;
        }
        if(cntc!=0)ok=false;
        cntc=0;
        repl(k,r,n){
          if(t[k]=='(')cntc++;
          if(t[k]==')')cntc--;
          if(cntc<0)ok=false;
        }
        if(cntc!=0)ok=false;
        if(!ok)break;
        int vl=calc_e(l,j); int vr=calc_e(r,n);
        if(l==j&&r==n&&vl!=-INF&&vr!=-INF&&vl==vr){
          res++;
        }
        break;
      }
    }
    return ;
  }
  rep(j,cand.size()){
    if(used[j])continue;
    used[j]=true;
    match.push_back(cand[j]);
    dfs(i+1);
    match.pop_back();
    used[j]=false;
  }
}

int main(){
  cin>>s;
  n=s.size();
  rep(i,n){
    if(exist(cand,s[i]))continue;
    cs.push_back(s[i]);
  }
  sort(all(cs));
  uni(cs);
  if(cs.size()>8){
    cout<<0<<endl;
    return 0;
  }
  dfs(0);
  cout<<res<<endl;
  return 0;
}

