#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int exp(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
using namespace std;
string doit(string s, long long int x) {
  reverse(s.begin(), s.end());
  string c, s1 = s;
  long long int carry = 0, a, i, n = s.size();
  for (i = 0; i < n; i++) {
    a = (s1[i] - '0') * x;
    s[i] = 48 + (a + carry) % 10;
    carry = (a + carry) / 10;
    if (i == n - 1 && carry != 0) {
      c = to_string(carry);
      reverse(c.begin(), c.end());
      s = s + c;
    }
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int i, n, x, c = 0;
  string s, ans = "1";
  cin >> s;
  n = s.size();
  map<char, long long int> m;
  if (s[0] == '?' || (s[0] >= 65 && s[0] <= 74)) {
    if (s[0] == '?')
      x = 10;
    else {
      m[s[0]] = 9;
      x = 9;
    }
    ans = doit(ans, 9);
  } else
    x = 10;
  for (long long int i = 1; i < n; i++) {
    if (s[i] == '?' || s[i] >= 65 && s[i] <= 74) {
      if (s[i] == '?')
        c++;
      else {
        if (m[s[i]] == 0) {
          m[s[i]] = x;
          ans = doit(ans, x);
          x--;
        }
      }
    }
  }
  cout << ans;
  for (long long int i = 0; i < c; i++) cout << 0;
  return 0;
}
