#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
template <typename T>
inline T BigMod(T A, T B) {
  T ret = 1;
  while (B) {
    if (B & 1) ret = (ret * A) % 998244353;
    A = (A * A) % 998244353;
    B = B >> 1;
  }
  return ret;
}
template <typename T>
inline T InvMod(T A, T M = 998244353) {
  return BigMod(A, M - 2);
}
string tostring(long long int res) {
  string curstr = "";
  if (!res) curstr += ((char)res + '0');
  while (res != 0) {
    long long int temp = (res % 10);
    curstr += ((char)temp + '0');
    res /= 10;
  }
  reverse(curstr.begin(), curstr.end());
  return curstr;
}
long long int toint(string ss) {
  long long int inss = 0;
  for (int i = 0; i < ss.size(); i++) {
    inss = (inss * 10) + ((int)(ss[i] - '0'));
  }
  return inss;
}
long long int fact[20], res, ncr[19][19];
string str;
int vis[19], taken[19], cnt[19];
map<vector<int>, int> mark;
vector<int> vv;
void genfact() {
  fact[0] = 1;
  for (long long int i = 1; i <= 20; i++) fact[i] = fact[i - 1] * i;
}
void genncr() {
  ncr[0][0] = 1;
  for (int i = 1; i <= 18; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0)
        ncr[i][j] = 1;
      else if (j == 1)
        ncr[i][j] = i;
      else
        ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]);
    }
  }
}
long long int calc(string cur) {
  int curcnt[10];
  memset(curcnt, 0, sizeof(curcnt));
  for (int i = 0; i < cur.length(); i++) curcnt[cur[i] - '0']++;
  for (int i = 0; i < 10; i++) vv.push_back(curcnt[i]);
  if (mark[vv]) return 0;
  long long int ans = fact[cur.length()];
  for (int i = 0; i < 10; i++) ans /= fact[curcnt[i]];
  if (!curcnt[0]) return ans;
  curcnt[0]--;
  long long int now = fact[cur.length() - 1];
  for (int i = 0; i < 10; i++) now /= fact[curcnt[i]];
  ans = ans - now;
  return ans;
}
void backtrack(int i, int ind, string cur) {
  if (i == str.length()) {
    vv.clear();
    long long int now = calc(cur);
    res += now;
    mark[vv] = 1;
    return;
  }
  string temp = cur;
  int now = str[i] - '0';
  if (!now && !ind) return;
  if (!vis[i]) {
    vis[i] = 1;
    if (taken[now] == 0) {
      taken[now]++;
      backtrack(i + 1, ind + 1, temp + str[i]);
    } else {
      backtrack(i + 1, ind, temp);
      if (taken[now] < cnt[now]) {
        taken[now]++;
        backtrack(i + 1, ind + 1, temp + str[i]);
      }
    }
    taken[now]--;
    vis[i] = 0;
  }
}
int main() {
  genfact();
  genncr();
  cin >> str;
  for (int i = 0; i < str.length(); i++) cnt[str[i] - '0']++;
  res = 0;
  backtrack(0, 0, "");
  cout << res << endl;
  return 0;
}
