#include <bits/stdc++.h>
const long long maxn = 19;
const long long maxbit = 1 << maxn;
std::string s;
long long n;
long long valid[maxbit];
long long dp[maxbit];
long long count[10];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin >> s;
  n = s.size();
  for (long long i = 0; i < n; i++) {
    count[s[i] - '0']++;
  }
  for (long long i = 0; i < (1 << n); i++) {
    long long bit_for_j = 0;
    valid[i] = true;
    for (long long j = 0; j < 10; j++) {
      if (count[j] and !((1 << bit_for_j) & i)) {
        valid[i] = false;
        break;
      }
      bit_for_j += count[j];
    }
  }
  for (long long i = (1 << n) - 1; i >= 0; i--) {
    dp[i] = valid[i];
    long long running_sum = 0;
    for (long long j = 0; j < 10; j++) {
      long long next_bit = running_sum + count[j];
      long long attempt_bit = running_sum;
      while (attempt_bit < next_bit and ((1 << attempt_bit) & i)) {
        attempt_bit++;
      }
      if (attempt_bit < next_bit and (i != 0 or j != 0)) {
        dp[i] += dp[i | (1 << attempt_bit)];
      }
      running_sum += count[j];
    }
  }
  std::cout << dp[0] << '\n';
}
