#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, n;
  long long int sum = 1;
  char s[10000];
  int A[10] = {0};
  string s1;
  int chk = 0;
  k = 10;
  s[0] = getchar();
  if (s[0] == '?') {
    chk = 0;
    sum *= 9;
    k = 10;
  } else if (s[0] >= 'A' && s[0] <= 'J') {
    chk = 1;
    A[s[0] - 65] = -1;
    sum *= 9;
    k = 9;
  }
  i = 1;
  while (1) {
    s[i] = getchar();
    if (s[i] == '\n') {
      break;
    }
    if (s[i] == '?') {
      s1 += '0';
    } else if ((s[i] >= 'A' && s[i] <= 'J') && A[s[i] - 65] == 0) {
      sum *= k;
      A[s[i] - 65]++;
      k--;
    }
    i++;
  }
  cout << sum << s1 << endl;
  return 0;
}
