#include <bits/stdc++.h>
int cnt[10];
char s[100000];
int fact(int n, int s) {
  int ans = 1;
  for (int i = 0; i < n; i++) ans *= (s - i);
  return ans;
}
int main() {
  int i;
  for (i = 0; i < 10; i++) cnt[i] = 0;
  char f;
  scanf(" %c", &f);
  scanf(" %s", s);
  int n = strlen(s);
  int ch = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '?')
      ch++;
    else if ('A' <= s[i] && s[i] <= 'J')
      cnt[s[i] - 'A']++;
  }
  int num = 0;
  for (i = 0; i < 10; i++)
    if (cnt[i] > 0) num++;
  int ans;
  if (f == '?') {
    ans = fact(num, 10) * 9;
    printf("%d", ans);
    for (i = 0; i < ch; i++) printf("0");
  } else if ('A' <= f && f <= 'J') {
    if (cnt[f - 'A'] == 0)
      ans = fact(num, 9) * 9;
    else
      ans = fact(num - 1, 9) * 9;
    printf("%d", ans);
    for (i = 0; i < ch; i++) printf("0");
  } else {
    ans = fact(num, 10);
    printf("%d", ans);
    for (i = 0; i < ch; i++) printf("0");
  }
  puts("");
  return 0;
}
