#include <bits/stdc++.h>
using namespace std;
string str;
long long n, dp[20][1 << 19], cmask, des;
long long rec(long long p, long long mask) {
  if (p == des) {
    long long ck = 0;
    for (int i = 0; i <= n - 1; i++) {
      long long ok = (long long)1 << i;
      if (!(mask & ok)) continue;
      long long v = str[i] - '0';
      ck = ck | (1 << v);
      if ((1 << v) < 0) cout << (1 << v) << endl;
    }
    if (ck == cmask)
      return 1;
    else
      return 0;
  }
  long long ck = 0;
  short rem[11];
  memset(rem, -1, sizeof(rem));
  for (int i = 0; i <= n - 1; i++) {
    long long ok = (long long)1 << i;
    if (mask & ok) continue;
    long long v = str[i] - '0';
    ck = ck | (1 << v);
    rem[v] = i;
  }
  long long &temp = dp[p][mask];
  if (temp != -1) return temp;
  temp = 0;
  for (int i = 0; i <= 9; i++) {
    if (p == 0 && i == 0) continue;
    long long ok = (long long)1 << i;
    if (ck & ok) {
      long long up = (long long)1 << rem[i];
      temp += rec(p + 1, mask | up);
    }
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(false);
  long long prin = 0;
  cin >> str;
  des = n = str.size();
  for (int i = 0; i <= n - 1; i++) {
    long long v = str[i] - '0';
    cmask = cmask | (1 << v);
  }
  while (des > 0) {
    memset(dp, -1, sizeof(dp));
    prin += rec(0, 0);
    des--;
  }
  cout << prin << endl;
  return 0;
}
