#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <iostream>
#include <set>
#include <cstring>

using namespace std;
typedef long long ll;

#define SIZE 500010
#define INF 1000000000

int term(char* &s);
int number(char* &s);
int factor(char* &s);
int expr(char* &s);

int term(char* &s){
  int res = factor(s), r;
  if(res == -INF) return res;
  while(1){
    if(*s == '*'){
      r = factor(++s);
      if(r == -INF) return r;
      res *= r;
    }else{
      break;
    }
  }
  return res;
}

int number(char* &s){
  int res = 0;

  if(!(*s)) return -INF;
  
  if(!('0' <= *s && *s <= '1')) return -INF;

  if(*s == '0' && (*(s+1) == '0' || *(s+1) == '1')) return -INF;
  
  while('0' <= *s && *s <= '1')
    res = res*2 + (*s++ - '0');

  return res;
}


int factor(char* &s){
  if(*s == ')') return -INF;
  
  if(*s == '-'){
    int r = factor(++s);
    if(r == -INF) return r;
    return r * -1;
  }
  if(*s != '(') return number(s);
  
  int res = expr(++s);
  if(*s != ')') return -INF;
  s++;
  return res;
}

int expr(char* &s) {
  int res = term(s), r;
  if(res == -INF) return res;
  while(1){
    if(*s == '+'){
      r = term(++s);
      if(r == -INF) return r;
      res += r;
    }else if(*s == '-'){
      r = term(++s);
      if(r == -INF) return r;
      res -= r;
    }else{
      if(*s == '(') return -INF;
      break;
    }
  }
  return res;
}

bool check(char *s){
  int counter = 0;
  while(*s){
    counter += (*s == '(') - (*s == ')');
    if(counter < 0) return false;
    s++;
    if(*s == ')' && (*(s+1) == '1' || *(s+1) == '0')) return false;
  }
  return counter == 0;
}

bool isop(char x){
  return x == '*' || x == '-' || x == '+' || x == '=' ||
    x == '(' || x == ')' || x == '0' || x == '1';
}

int main(){
  char s[50];
  vector<char> vec;
  map<char,int> dic;
  
  scanf("%s", s);

  for(int i=0;s[i];i++){
    if(!isop(s[i]))
      vec.push_back(s[i]);
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  //for(int i=0;i<vec.size();i++) cerr << vec[i] << endl;
  
  if(vec.size() > 8){
    puts("0");
    return 0;
  }

  for(int i=0;i<vec.size();i++) dic[vec[i]] = i;

  char op[] = "01+-*()=";
  sort(op, op+8);

  int n = strlen(s);
  int ans = 0;
  
  char d[50];
  d[n] = '\0';

  set<string> ss;
  
  do{
    string r = op;
    r = r.substr(0, vec.size());
    if(ss.find(r) != ss.end()) continue;
    ss.insert(r);
    
    int eq = -1;
    
    for(int i=0;s[i];i++){
      if(isop(s[i])) d[i] = s[i];
      else d[i] = op[dic[s[i]]];

      if(d[i] == '='){
        if(eq == -1) eq = i;
        else eq = -2;
      }
    }
    
    if(eq < 0 || eq == 0 || eq == n-1) continue;
    d[eq] = '\0';
    
    char *p = d, *q = d + eq + 1;
    if(!check(p) || !check(q)) continue;
    
    int res1 = expr(p);
    int res2 = expr(q);

    //if(res1 != -INF) cerr << d << endl;
    //if(res2 != -INF) cerr << d + eq + 1 << endl;
    
    if(res1 != -INF && res1 == res2){
      ans++;
      d[eq] = '=';
    }
  }while(next_permutation(op, op+8));
 
  printf("%d\n", ans);
}

