#include <bits/stdc++.h>
using namespace std;
int arr[10][10];
bool CheckArr(const string& s) {
  const int n = s.length();
  for (int a = 0; a < (10); ++a) {
    if (arr[a][0] == 0) continue;
    char c = s[arr[a][0] - 1];
    for (int i = 0; i < (10); ++i) {
      if (arr[a][i] == 0) break;
      int idx = arr[a][i] - 1;
      if (c != s[idx]) return false;
    }
  }
  for (int i = 0; i < 10; ++i) {
    if (arr[i][0] == 0) continue;
    for (int j = i + 1; j < 10; ++j) {
      if (arr[j][0] == 0) continue;
      int idx1 = arr[i][0] - 1;
      int idx2 = arr[j][0] - 1;
      if (s[idx1] == s[idx2]) return false;
    }
  }
  return true;
}
bool Check(const string& s1, const string& s2) {
  const int n = s1.length();
  if (n != s2.length()) return false;
  for (int i = 0; i < (n); ++i) {
    if (s1[i] == '?') continue;
    if (s1[i] >= '0' && s1[i] <= '9' && s1[i] == s2[i]) continue;
    if (s1[i] >= 'A' && s1[i] <= 'J') continue;
    return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  const int n = s.length();
  if (n > 5) {
    cout << ":(" << endl;
    return 0;
  }
  for (int i = 0; i < (n); ++i)
    if (s[i] >= 'A' && s[i] <= 'J') {
      int alphaIdx = s[i] - 'A';
      int posIdx = 0;
      while (arr[alphaIdx][posIdx] != 0) ++posIdx;
      arr[alphaIdx][posIdx] = i + 1;
    }
  int ans = 0;
  for (int i = 1; i <= 99999; ++i) {
    char str[6];
    sprintf(str, "%d", i);
    string s2(str);
    if (Check(s, s2) && CheckArr(s2)) ++ans;
  }
  cout << ans << endl;
  return 0;
}
