#include <bits/stdc++.h>
using namespace std;
int cnt1;
int ans[100100], st[100100], num2[10];
void hpm(int num) {
  int cnt2 = 0;
  while (num > 0) {
    num2[++cnt2] = num % 10;
    num /= 10;
  }
  int t = 0;
  memset(st, 0, sizeof(st));
  for (int i = 1; i <= cnt1; i++) {
    for (int k = 1; k <= cnt2; k++) {
      t = ans[i] * num2[k] + t;
      int tt = st[i + k - 1];
      st[i + k - 1] = (st[i + k - 1] + t) % 10;
      t = (tt + t) / 10;
    }
    if (t != 0) {
      st[cnt2 + i] += t;
      t /= 10;
    }
  }
  for (int i = 1; i <= cnt1 + cnt2; i++) ans[i] = st[i];
  int po;
  for (int i = cnt1 + cnt2; i >= 1; i--)
    if (ans[i] != 0) {
      po = i;
      break;
    }
  cnt1 = po;
  return;
}
char s[100100], vis[30];
int main() {
  while (scanf("%s", s) == 1) {
    int l = strlen(s);
    memset(vis, 0, sizeof(vis));
    memset(ans, 0, sizeof(ans));
    cnt1 = 1;
    ans[1] = 1;
    int ant = 10;
    for (int i = 0; i < l; i++) {
      if (s[i] == '?') {
        if (i != 0)
          hpm(10);
        else
          hpm(9);
      } else if (s[i] >= 'A' && s[i] <= 'J') {
        int c = s[i] - 'A';
        if (vis[c] == 0 && ant != 0) {
          if (i == 0)
            hpm(9);
          else
            hpm(ant);
          vis[c] = 1;
          ant--;
        }
      }
    }
    for (int i = cnt1; i >= 1; i--) printf("%d", ans[i]);
    printf("\n");
  }
  return 0;
}
