#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998242353, mod2 = 1e9 + 9,
                inf = 1e9 + 7;
const long long infll = 1e18 + 7;
string s;
bool a[10];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  long long n = s.length();
  for (long long i = 0; i < n; i++) {
    if (s[i] >= 'A' && s[i] <= 'J') {
      a[s[i] - 'A'] = 1;
    }
  }
  long long ans = 1;
  long long idx = -1;
  long long k = 0;
  if (s[0] >= 'A' && s[0] <= 'J') {
    idx = s[0] - 'A';
    ans *= 9;
    k = 1;
  } else if (s[0] == '?') {
    ans *= 9;
  }
  for (long long i = 1; i < n; i++) {
    if (s[i] == '?') ans *= 10;
  }
  for (long long i = 0; i < 10; i++) {
    if (i == idx) continue;
    if (a[i]) {
      ans *= (10 - k);
      k++;
    }
  }
  cout << ans;
}
