#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

string str;
int now;

int E();
int T();
int F();
int N();

int E(){
  int t = T();
  if(t==INF) return INF;
  while(str[now+1]=='+' || str[now+1]=='-'){
    if(str[now+1]=='+'){
      now++;
      int p = T();
      if(p==INF) return INF;
      else t = t+p;
    }
    if(str[now+1]=='-'){
      now++;
      int p = T();
      if(p==INF) return INF;
      else t = t-p;
    }
  }
  return t;
}

int T(){
  int f = F();
  if(f==INF) return INF;

  if(str[now+1]=='*'){
    now++;
    int g = T();
    if(g==INF) return INF;
    else return f*g;
  }
  return f;
}

int F(){
  int n;
  switch(str[now+1]){
    case '0':
    case '1':
      n=N();
      if(n==INF) return INF;
      else return n;
    case '-':
      now++;
      n=F();
      if(n==INF) return INF;
      else return -n;
    case '(':
      now++;
      n = E();
      if(str[now+1]!=')' || n==INF) return INF;
      now++;
      return n;
    default:
      return INF;
  }
}

int N(){
  if(str[now+1]=='0'){
    now++;
    return 0;
  }
  if(str[now+1]!='1') return INF;
  now++;
  int res=1;
  while(str[now+1]=='1' || str[now+1]=='0'){
    now++;
    res = res*2 + str[now] - '0';
  }
  return res;
}

int main(){
  string s;
  cin>>s;
  set<char> m, mm;
  string moji = "=+-*()01";
  sort(all(moji));

  rep(i,s.size()){
    bool found=false;
    rep(j,moji.size()) if(s[i]==moji[j]){
      mm.insert(s[i]);
      found=true;
    }
    if(!found) m.insert(s[i]);
  }

  if(m.size()>moji.size()){
    cout<<0<<endl;
    return 0;
  }

  int ans=0;
  do { //next_permutation moji
    string newstr(s);

    auto itr = m.begin();
    rep(i, m.size()){
      rep(j, newstr.size()) if(newstr[j]==*itr){
        newstr[j] = moji[i];
      }
      itr++;
    }

    int idx = newstr.find('=');
    if(idx>0 && idx<newstr.size()-1){ // not ('=' is not found or at the head of string)
      str = newstr.substr(0, idx) + '\0';
      now = -1;
      int l = E();

      if(l!=INF && now==idx-1){
        str = newstr.substr(idx+1) + '\0';
        now = -1;
        int r= E();

        if(now==str.size()-2 && r==l) ans++;
      }
    }

    reverse(moji.begin()+m.size(), moji.end());

  } while(next_permutation(all(moji)));

  cout<<ans<<endl;

  return 0;
}