#include <bits/stdc++.h>
using namespace std;
typedef int bign[20001];
char s[120001];
bign ans;
bool vis[10];
void mul(int x) {
  if (x == 1) return;
  for (int i = 1; i <= ans[0]; i++) ans[i] *= x;
  for (int i = 1; i <= ans[0]; i++) {
    ans[i + 1] += ans[i] / 100000000;
    ans[i] %= 100000000;
  }
  if (ans[ans[0] + 1]) ans[0]++;
}
void print() {
  printf("%d", ans[ans[0]]);
  for (int i = ans[0] - 1; i >= 1; i--) {
    int temp = ans[i];
    int cnt = 0;
    while (temp) {
      cnt++;
      temp /= 10;
    }
    for (int j = cnt + 1; j <= 8; j++) printf("0");
    if (ans[i]) printf("%d", ans[i]);
  }
  printf("\n");
}
int main() {
  scanf("%s", s);
  int l = strlen(s);
  int t = 0, q = 0;
  bool f1 = false, f2 = false;
  for (int i = 0; i < l; i++) {
    char c = s[i];
    if (c == '?') {
      q++;
      if (i == 0) f2 = true;
    }
    if (c >= 'A' && c <= 'J') {
      vis[c - 'A'] = true;
      if (i == 0) f1 = true;
    }
  }
  ans[0] = ans[1] = 1;
  if (q) {
    if (f2)
      mul(9);
    else
      mul(10);
    for (int i = 2; i <= q; i++) mul(10);
  }
  int cur = 10;
  for (int i = 0; i <= 9; i++)
    if (vis[i]) {
      if (f1) {
        mul(9);
        f1 = false;
      } else
        mul(cur);
      cur--;
    }
  print();
  return 0;
}
