#include <bits/stdc++.h>
using namespace std;
char str[100010];
bool cha[30];
int a, b;
int res[100010], len;
void fun(int x) {
  int c = 0;
  for (int i = 0; i < len; i++) {
    res[i] = res[i] * x + c;
    c = res[i] / 10;
    res[i] %= 10;
  }
  if (c) {
    int i = len;
    while (c) {
      res[i] = c % 10;
      c /= 10;
      i++;
    }
    len = i;
  }
}
void move(int x) {
  for (int i = len - 1; i >= 0; i--) res[i + x] = res[i];
  for (int i = 0; i < a; i++) res[i] = 0;
  len += x;
}
void cal(int s) {
  move(a);
  for (int i = 0, j = s; i < b; i++, j--) fun(j);
}
int main() {
  a = b = 0;
  memset(cha, false, sizeof(cha));
  cin >> str;
  for (int i = 0; str[i]; i++)
    if (str[i] >= 'A' && str[i] <= 'Z') {
      if (!cha[str[i] - 'A']) b++;
      cha[str[i] - 'A'] = true;
    } else if (str[i] == '?')
      a++;
  res[0] = 1;
  len = 1;
  if (str[0] >= 'A' && str[0] <= 'Z') {
    res[0] = 9;
    b--;
    cal(9);
  } else if (str[0] == '?') {
    res[0] = 9;
    a--;
    cal(10);
  } else
    cal(10);
  for (int i = len - 1; i >= 0; i--) cout << res[i];
  cout << endl;
  return 0;
}
