#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
char s[N];
vector<int> c;
int main() {
  scanf("%s", s);
  int x = 0;
  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
      x++;
    } else if ('A' <= s[i] && s[i] <= 'J') {
      c.push_back(s[i] - 'A');
    }
  }
  sort(c.begin(), c.end());
  c.resize(unique(c.begin(), c.end()) - c.begin());
  long long ans = 1;
  for (int i = 0; i < c.size(); i++) {
    ans *= 10 - i;
  }
  if ('A' <= s[0] && s[0] <= 'J') {
    int cnt = 0;
    int ch = s[0] - 'A';
    long long d = 1;
    for (int j = 0; j < c.size(); j++) {
      if (ch != c[j]) {
        d *= 9 - cnt;
        ++cnt;
      }
    }
    ans -= d;
  } else if (s[0] == '?') {
    x--;
    ans *= 9;
  }
  printf("%lld", ans);
  for (int i = 0; i < x; i++) {
    printf("0");
  }
  puts("");
  return 0;
}
