/*  -*- coding: utf-8 -*-
 *
 * 1371.cc: Infallibly Crack Perplexing Cryptarithm
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int CN = 8;
const char cs[] = "01+-*()=";

const int MAX_PN = 40320; // = 8!
const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

char s[64], t[64];
int vmap[128], cns[CN], pss[MAX_PN][CN], ps[CN], pn = 0;
bool used[CN];

/* subroutines */

void rec_perm(int u, int vn) {
  if (u >= vn) {
    memcpy(pss[pn++], ps, sizeof(pss[0]));
    return;
  }

  for (int c = 0; c < CN; c++)
    if (! used[c]) {
      used[c] = true;
      ps[u] = c;
      rec_perm(u + 1, vn);
      used[c] = false;
    }
}

ll expr(char *(&cpt));

ll num(char *(&cpt)) {
  bool swz = (*cpt == '0');
  ll v0 = 0;
  int l = 0;
  while (*cpt == '0' || *cpt == '1')
    v0 = (v0 << 1) | (*(cpt++) - '0'), l++;
  if (swz && l > 1) return LINF;
  return v0;
}

ll factor(char *(&cpt)) {
  if (*cpt == '0' || *cpt == '1') return num(cpt);
  if (*cpt == '-') {
    cpt++; // '-;
    ll v0 = factor(cpt);
    if (v0 >= LINF) return LINF;
    return -v0;
  }
  if (*cpt == '(') {
    cpt++; // '('
    ll v0 = expr(cpt);
    if (v0 >= LINF || *cpt != ')') return LINF;
    cpt++; // ')'
    return v0;
  }
  return LINF;
}

ll term(char *(&cpt)) {
  ll v0 = factor(cpt);
  if (v0 >= LINF) return LINF;

  while (*cpt == '*') {
    cpt++; // '*'
    ll v1 = factor(cpt);
    if (v1 >= LINF) return LINF;
    v0 *= v1;
  }
  return v0;
}

ll expr(char *(&cpt)) {
  ll v0 = term(cpt);
  if (v0 >= LINF) return LINF;

  while (*cpt == '+' || *cpt == '-') {
    char op = *(cpt++); // '+' || '-'
    ll v1 = term(cpt);
    if (v1 >= LINF) return LINF;
    if (op == '+') v0 += v1;
    else v0 -= v1;
  }
  return v0;
}

/* main */

int main() {
  scanf("%s", s);

  memset(vmap, -1, sizeof(vmap));
  int vn = 0;
  for (int i = 0; s[i]; i++) {
    if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) {
      int vid = vmap[s[i]];
      if (vid < 0) vid = vmap[s[i]] = vn++;
      s[i] = vid + 1;
      cns[vid]++;
    }

    //if (s[i] < vn) printf("[%d]", s[i]);
    //else putchar(s[i]);
  }
  //putchar('\n');

  if (vn > CN) {
    puts("0");
    return 0;
  }

  rec_perm(0, vn);
  //printf("pn=%d\n", pn);

  int cnt = 0;
  for (int pi = 0; pi < pn; pi++) {
    int eql = 0, obr = 0, cbr = 0;
    for (int i = 0; s[i]; i++) {
      if (s[i] <= vn) t[i] = cs[pss[pi][s[i] - 1]];
      else t[i] = s[i];
      switch (t[i]) {
      case '=': eql++; break;
      case '(': obr++; break;
      case ')': cbr++; break;
      }
    }
    if (eql != 1 || obr != cbr) continue;
    //puts(t);

    char *cpt = t;
    ll v0 = expr(cpt);
    if (v0 < LINF && *cpt == '=') {
      cpt++; // '='
      ll v1 = expr(cpt);
      if (v1 < LINF && v0 == v1 && *cpt == '\0') {
	cnt++;
	//puts(t);
      }
    }
  }

  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 4480