#include <bits/stdc++.h>
using namespace std;
int b[11];
int p[100000];
int main() {
  string a;
  long long int c = 0, c1 = 0, i;
  cin >> a;
  long long int l = a.size(), x = 10;
  ;
  long long int ans = 1, y = 1;
  for (i = 0; i < l; i++) {
    if (a[i] >= 'A' && a[i] <= 'J' && b[a[i] - 65] == 0) {
      c1++;
      b[a[i] - 65] = 1;
    } else if (a[i] == '?')
      c++;
  }
  while (c1) {
    y *= x;
    x--;
    c1--;
  }
  p[c] = 1;
  if (a[0] >= 'A' && a[0] <= 'J') {
    y *= 9;
    y /= 10;
  }
  if (c < 1) {
    cout << y;
    return 0;
  } else {
    if (a[0] == '?') {
      p[c - 1] = 9;
      c--;
    }
    x = p[c] * y;
    while (x > 0) {
      p[c] = x % 10;
      x = x / 10;
      c++;
    }
    for (i = c - 1; i >= 0; i--) cout << p[i];
  }
  return 0;
}
