#include <bits/stdc++.h>
char letter[100001];
bool has_letter[10];
char zero_end[100001];
int num_accu[11] = {1,     1,     9,      72,     504,   3024,
                    15120, 60480, 181440, 362880, 362880};
int main() {
  int i, ques_cnt = 0, digit_0 = 0, letter_cnt = 0, letter_0 = 0;
  int result = 1;
  scanf("%s", letter);
  if (letter[0] == '?')
    result = 9;
  else if (letter[0] >= 'A' && letter[0] <= 'J') {
    letter_0 = 1;
    has_letter[letter[0] - 'A'] = true;
  }
  int len = strlen(letter);
  for (i = 1; i < len; ++i) {
    if (letter[i] >= 'A' && letter[i] <= 'J')
      has_letter[letter[i] - 'A'] = true;
    else if (letter[i] == '?')
      ++ques_cnt;
  }
  for (i = 0; i < 10; ++i)
    if (has_letter[i]) ++letter_cnt;
  if (letter_0 == 1 && letter_cnt == 1)
    result *= 9;
  else if (letter_cnt > 0) {
    if (letter_0 == 1)
      result *= 9;
    else
      result *= 10;
    result *= num_accu[letter_cnt];
  }
  memset(zero_end, '0', sizeof(char) * ques_cnt);
  zero_end[ques_cnt] = '\0';
  printf("%d%s\n", result, zero_end);
  return 0;
}
