#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  while (cin >> str) {
    int hah[10] = {0};
    int n1 = 0;
    string stemp;
    for (int i = 0; i < str.length(); i++) {
      if (str[i] >= 'A' && str[i] <= 'J') {
        if (hah[str[i] - 'A'] == 0) {
          n1++;
          hah[str[i] - 'A']++;
        }
      } else if (str[i] == '?') {
        stemp += '0';
      }
    }
    long long ans = 1;
    for (int i = 0; i < n1; i++) {
      ans *= 10 - i;
    }
    if (str[0] >= 'A' && str[0] <= 'J') {
      ans /= 10;
      ans *= 9;
    } else if (str[0] == '?') {
      ans *= 9;
      stemp.erase(stemp.begin(), stemp.begin() + 1);
    }
    cout << ans << stemp << endl;
  }
  return 0;
}
