#include <bits/stdc++.h>
using namespace std;
long long rec1(long long n) {
  long long ans = 0;
  if (n == 1) {
    for (int i = 0; i < 10; i++) {
      if (i != 0) ans++;
    }
  } else if (n == 2) {
    for (int i = 0; i < 10; i++) {
      for (int k = 0; k < 10; k++)
        if (i != 0 && i != k) ans++;
    }
  } else if (n == 3) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          if (i != 0 && i != k && i != c && k != c) ans++;
  } else if (n == 4) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            if (i != 0 && i != k && i != c && i != d && k != c && k != d &&
                c != d)
              ans++;
  } else if (n == 5) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              if (i != 0 && i != k && i != c && i != d && i != e && k != c &&
                  k != d && k != e && c != d && c != e && d != e)
                ans++;
  } else if (n == 6) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                if (i != 0 && i != k && i != c && i != d && i != e && i != f &&
                    k != c && k != d && k != e && k != f && c != d && c != e &&
                    c != f && d != e && d != f && e != f)
                  ans++;
  } else if (n == 7) {
    for (int i = 1; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  if (i != k && i != c && i != d && i != e && i != f &&
                      i != g && k != c && k != d && k != e && k != f &&
                      k != g && c != d && c != e && c != f && c != g &&
                      d != e && d != f && d != g && e != f && e != g && f != g)
                    ans++;
  } else if (n == 8) {
    for (int i = 1; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  for (int h = 0; h < 10; h++)
                    if (i != k && i != c && i != d && i != e && i != f &&
                        i != g && i != h && k != c && k != d && k != e &&
                        k != f && k != g && k != h && c != d && c != e &&
                        c != f && c != g && c != h && d != e && d != f &&
                        d != g && d != h && e != f && e != g && e != h &&
                        f != g && f != h && g != h)
                      ans++;
  } else if (n == 9) {
    for (int i = 1; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  for (int h = 0; h < 10; h++)
                    for (int j = 0; j < 10; j++)
                      if (i != k && i != c && i != d && i != e && i != f &&
                          i != g && i != h && i != j && k != c && k != d &&
                          k != e && k != f && k != g && k != h && k != j &&
                          c != d && c != e && c != f && c != g && c != h &&
                          c != j && d != e && d != f && d != g && d != h &&
                          d != j && e != f && e != g && e != j && e != h &&
                          f != g && f != h && f != j && g != h && g != j &&
                          h != j)
                        ans++;
  }
  return ans;
}
long long rec(long long n) {
  long long ans = 0;
  if (n == 1) {
    for (int i = 0; i < 10; i++) {
      ans++;
    }
  } else if (n == 2) {
    for (int i = 0; i < 10; i++) {
      for (int k = 0; k < 10; k++)
        if (i != k) ans++;
    }
  } else if (n == 3) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          if (i != k && i != c && k != c) ans++;
  } else if (n == 4) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            if (i != k && i != c && i != d && k != c && k != d && c != d) ans++;
  } else if (n == 5) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              if (i != k && i != c && i != d && i != e && k != c && k != d &&
                  k != e && c != d && c != e && d != e)
                ans++;
  } else if (n == 6) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                if (i != k && i != c && i != d && i != e && i != f && k != c &&
                    k != d && k != e && k != f && c != d && c != e && c != f &&
                    d != e && d != f && e != f)
                  ans++;
  } else if (n == 7) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  if (i != k && i != c && i != d && i != e && i != f &&
                      i != g && k != c && k != d && k != e && k != f &&
                      k != g && c != d && c != e && c != f && c != g &&
                      d != e && d != f && d != g && e != f && e != g && f != g)
                    ans++;
  } else if (n == 8) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  for (int h = 0; h < 10; h++)
                    if (i != k && i != c && i != d && i != e && i != f &&
                        i != g && i != h && k != c && k != d && k != e &&
                        k != f && k != g && k != h && c != d && c != e &&
                        c != f && c != g && c != h && d != e && d != f &&
                        d != g && d != h && e != f && e != g && e != h &&
                        f != g && f != h && g != h)
                      ans++;
  } else if (n == 9) {
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            for (int e = 0; e < 10; e++)
              for (int f = 0; f < 10; f++)
                for (int g = 0; g < 10; g++)
                  for (int h = 0; h < 10; h++)
                    for (int j = 0; j < 10; j++)
                      if (i != k && i != c && i != d && i != e && i != f &&
                          i != g && i != h && i != j && k != c && k != d &&
                          k != e && k != f && k != g && k != h && k != j &&
                          c != d && c != e && c != f && c != g && c != h &&
                          c != j && d != e && d != f && d != g && d != h &&
                          d != j && e != f && e != g && e != j && e != h &&
                          f != g && f != h && f != j && g != h && g != j &&
                          h != j)
                        ans++;
  }
  return ans;
}
int main() {
  string x;
  while (cin >> x) {
    long long ans = 1;
    int vis[26] = {0};
    int CHn = 0;
    int F = 0;
    for (int i = 0; i < x.size(); i++) {
      if ((x[i] >= 'A' && x[i] <= 'Z') && i != 0 && !vis[x[i] - 'A']) {
        CHn++;
        vis[x[i] - 'A'] = 1;
      } else if ((x[i] >= 'A' && x[i] <= 'Z') && i == 0 && !vis[x[i] - 'A']) {
        F++;
        vis[x[i] - 'A'] = 1;
      }
    }
    for (int i = 0; i < x.size(); i++) {
      if (x[i] >= '0' && x[i] <= '9')
        ans *= 1;
      else if (x[i] == '\?') {
        if (i == 0)
          ans *= 9;
        else
          ans *= 10;
      }
    }
    if (F != 0) {
      ans *= rec1(F + CHn);
    } else if (CHn > 0) {
      ans *= rec(CHn);
    }
    cout << ans << endl;
  }
  return 0;
}
