#include <bits/stdc++.h>
const int N = 100010;
using namespace std;
struct Big {
  static const int maxn = 1009, BIT = 10000;
  int s[maxn], l;
  Big();
  Big(int b);
  Big(char *str);
  template <typename T>
  void operator=(T b);
  bool operator<(const Big &b);
  bool operator==(const Big &b);
  bool operator>(const Big &b);
  bool operator<=(const Big &b);
  bool operator>=(const Big &b);
  Big operator+(const Big &b);
  Big operator*(const Big &b);
  Big operator-(const Big &b);
  Big operator/(const int &b);
  void out();
};
Big::Big() { memset(s, 0, sizeof(s)), l = 1; }
Big::Big(int b) {
  memset(s, 0, sizeof(s)), l = 0;
  while (b) s[l++] = b % BIT, b /= BIT;
  l = (!l) ? 1 : l;
}
Big::Big(char *str) {
  memset(s, 0, sizeof(s)), l = 0;
  int i, j, p;
  for (i = strlen(str) - 1; i >= 0; i -= 4) {
    for (p = 0, j = max(i - 3, 0); j <= i; p = p * 10 + str[j] - '0', ++j)
      ;
    s[l++] = p;
  }
  while (!s[l - 1] && l - 1) l--;
}
template <typename T>
void Big::operator=(T b) {
  Big tmp(b);
  (*this) = tmp;
}
bool Big::operator<(const Big &b) {
  if (l != b.l) return l < b.l;
  for (int i = l - 1; i >= 0; i--)
    if (s[i] != b.s[i]) return s[i] < b.s[i];
  return 0;
}
bool Big::operator==(const Big &b) {
  if (l != b.l) return 0;
  for (int i = l - 1; i >= 0; i--)
    if (s[i] != b.s[i]) return 0;
  return 1;
}
bool Big::operator>(const Big &b) { return !((*this) < b || (*this) == b); }
bool Big::operator<=(const Big &b) { return (*this) < b || (*this) == b; }
bool Big::operator>=(const Big &b) { return (*this) > b || (*this) == b; }
Big Big::operator+(const Big &b) {
  Big c;
  c.l = max(l, b.l);
  for (int i = 0; i < c.l; ++i)
    c.s[i] += s[i] + b.s[i], c.s[i + 1] += c.s[i] / BIT, c.s[i] %= BIT;
  while (c.s[c.l]) c.s[c.l + 1] += c.s[c.l] / BIT, c.s[c.l++] %= BIT;
  return c;
}
Big Big::operator*(const Big &b) {
  Big c;
  for (int i = 0; i < l; i++)
    for (int j = 0; j < b.l; j++)
      c.s[i + j] += s[i] * b.s[j], c.s[i + j + 1] += c.s[i + j] / BIT,
          c.s[i + j] %= BIT;
  c.l = l + b.l;
  while (!c.s[c.l - 1] && c.l - 1) c.l--;
  return c;
}
Big Big::operator-(const Big &b) {
  Big c = (*this);
  for (int i = 0; i < c.l; i++)
    if ((c.s[i] -= b.s[i]) < 0) c.s[i + 1]--, c.s[i] += BIT;
  while (c.l - 1 && !c.s[c.l - 1]) c.l--;
  return c;
}
Big Big::operator/(const int &b) {
  Big c;
  for (int i = l - 1, x = 0; i >= 0; i--)
    x = x * BIT + s[i], c.s[i] = x / b, x %= b;
  c.l = l;
  while (c.l - 1 && !c.s[c.l - 1]) c.l--;
  return c;
}
void Big::out() {
  printf("%d", s[l - 1]);
  for (int i = l - 2; i >= 0; i--) printf("%04d", s[i]);
}
char s[N];
int vis[11];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  Big ret;
  ret = 1;
  int t = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] >= '0' && s[i] <= '9') continue;
    if (s[i] >= 'A' && s[i] <= 'J') vis[s[i] - 'A'] = 1;
    if (s[i] == '?') {
      if (i)
        t++;
      else
        ret = ret * 9;
    }
  }
  int cnt = 0;
  for (int i = 0; i < 10; i++)
    if (vis[i]) cnt++;
  if (s[0] >= 'A' && s[0] <= 'J') {
    ret = ret * 9;
    for (int i = cnt - 1, j = 9; i > 0; i--) ret = ret * j, j--;
  } else {
    for (int i = cnt, j = 10; i > 0; i--) ret = ret * j, j--;
  }
  ret.out();
  for (int i = 0; i < t; i++) printf("0");
  puts("");
  return 0;
}
