#include <bits/stdc++.h>
using namespace std;
int setBit(int n, int pos) { return n = n | (1 << pos); }
int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
bool checkBit(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
char str[21];
bool ase[12];
long long dp[(1 << 19) + 10];
int vis[(1 << 19) + 10];
int cur, len;
int check(int mask) {
  bitset<11> now = 0;
  for (int i = 0; i < len; i++) {
    if (checkBit(mask, i)) now[str[i] - '0'] = 1;
  }
  for (int i = 0; i < 10; i++) {
    if (now[i] == 0 and ase[i]) {
      return 0;
    }
  }
  return 1;
}
long long call(int cnt, int mask) {
  if (cnt == cur) return check(mask);
  if (vis[mask] == cur) return dp[mask];
  vis[mask] = cur;
  long long ret = 0;
  bitset<11> now = 0;
  for (int i = 0; i < len; i++) {
    if (checkBit(mask, i) == 0) {
      if (now[str[i] - '0'] == 0 and !(str[i] == '0' and cnt == 0)) {
        ret += call(cnt + 1, setBit(mask, i));
        now[str[i] - '0'] = 1;
      }
    }
  }
  return dp[mask] = ret;
}
int main() {
  long long n;
  scanf("%lld", &n);
  sprintf(str, "%lld", n);
  len = strlen(str);
  for (int i = 0; i < len; i++) {
    ase[str[i] - '0'] = true;
  }
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  for (int i = 1; i <= len; i++) {
    cur = i;
    ans += call(0, 0);
  }
  printf("%lld\n", ans);
  return 0;
}
