#include <bits/stdc++.h>
using namespace std;
string ss, s;
int ans, kol;
bool was[1111], can[11];
int dlen(int n) {
  int ans = 0;
  if (n == 0) return 1;
  while (n > 0) {
    ans++;
    n /= 10;
  }
  return ans;
}
string str(int n) {
  string s;
  if (n == 0) {
    s = "0";
    return s;
  }
  while (n > 0) {
    char c = (n % 10) + 48;
    s = c + s;
    n /= 10;
  }
  return s;
}
bool isgood(string s1, string s2) {
  if (s1.length() != s2.length()) return false;
  for (int i = 0; i < s1.length(); i++)
    if (s1[i] != s2[i] && s1[i] >= 48 && s1[i] <= 57 && s2[i] >= 48 &&
        s2[i] <= 57)
      return false;
  for (int i = 0; i < s1.length(); i++)
    for (int j = i + 1; j < s1.length(); j++)
      if (s1[i] == s1[j] && s1[i] >= 65 && s1[i] <= 90 && s2[i] != s2[j] &&
          s2[i] >= 48 && s2[i] <= 57 && s2[j] >= 48 && s2[j] <= 57)
        return false;
  for (int i = 0; i < s2.length(); i++)
    for (int j = i + 1; j < s2.length(); j++)
      if (s2[i] == s2[j] && s2[i] >= 48 && s2[i] <= 57 && s1[i] != s1[j] &&
          s1[i] >= 65 && s1[i] <= 90 && s1[j] >= 65 && s1[j] <= 90)
        return false;
  return true;
}
int main() {
  getline(cin, s);
  if (s.length() == 1) {
    if (s[0] >= 48 && s[0] <= 57)
      cout << 1 << endl;
    else
      cout << 9 << endl;
    return 0;
  }
  for (int ch = 0; ch <= 99999; ch++) {
    string s1 = str(ch);
    if (isgood(s, s1)) ans++;
  }
  cout << ans << endl;
  return 0;
}
