#include <bits/stdc++.h>
using namespace std;
string h1;
bool s[10001];
int h[1000001];
int size = 1;
void cheng(int t) {
  int u = 0;
  for (int i = 0; i < size; i++) {
    h[i] *= t;
    h[i] += u;
    u = h[i] / 10;
    h[i] %= 10;
  }
  h[size] = u;
  if (h[size] > 0) size++;
  return;
}
int main() {
  h[0] = 1;
  cin >> h1;
  for (int i = 0; i < h1.size(); i++) {
    if (h1[i] == '?')
      cheng(10 - (i == 0));
    else if (h1[i] >= 'A' && h1[i] <= 'J')
      s[int(h1[i])] = 1;
  }
  int tot = 0;
  for (int i = 0; i < 300; i++)
    if (s[i]) tot++;
  int strat = 10;
  if (h1[0] >= 'A' && h1[0] <= 'J') {
    cheng(9);
    strat--;
    tot--;
  }
  for (strat; tot > 0; tot--, strat--) cheng(strat);
  for (int i = size - 1; i >= 0; i--) cout << h[i];
  cout << endl;
  return 0;
}
