#include <bits/stdc++.h>
using namespace std;
map<pair<long long int, long long int>, long long int> memways;
long long int encode(int howmany[20]) {
  long long int x = 0;
  int b = 0;
  for (int i = 1; i < 20; i++) {
    for (int d = 0; d < howmany[i]; d++, b++) x |= 1 << b;
    b++;
  }
  return x;
}
int howmany[2][20];
pair<long long int, long long int> encode() {
  return pair<long long int, long long int>(encode(howmany[0]),
                                            encode(howmany[1]));
}
long long int ways() {
  pair<long long int, long long int> c = encode();
  if (memways.count(c)) return memways[c];
  long long int &sol = memways[c];
  bool thereis = false;
  for (int i = 1; i < 20; i++) {
    if (howmany[0][i]) {
      thereis = true;
      long long int available = howmany[0][i];
      howmany[0][i]--;
      howmany[1][i - 1]++;
      sol += available * ways();
      howmany[0][i]++;
      howmany[1][i - 1]--;
    }
  }
  sol += not thereis;
  for (int i = 1; i < 20; i++) {
    if (howmany[1][i]) {
      long long int available = howmany[1][i];
      howmany[1][i]--;
      howmany[1][i - 1]++;
      sol += available * ways();
      howmany[1][i]++;
      howmany[1][i - 1]--;
    }
  }
  return sol;
}
int amount[10];
int main() {
  long long int n;
  cin >> n;
  for (; n; n /= 10) amount[n % 10]++;
  for (int i = 0; i < 10; i++) howmany[0][amount[i]]++;
  long long int sol = 0;
  for (int i = 1; i < 20; i++) {
    if (howmany[0][i] > (amount[0] == i)) {
      long long int available = howmany[0][i] - (amount[0] == i);
      howmany[0][i]--;
      howmany[1][i - 1]++;
      sol += available * ways();
      howmany[0][i]++;
      howmany[1][i - 1]--;
    }
  }
  cout << sol << endl;
}
