#include <bits/stdc++.h>
using namespace std;
bool dig[15];
vector<int> divs;
vector<int> pows;
int n, k = 0;
bool try_a(int a) {
  while (a > 0) {
    if (dig[a % 10]) {
      return true;
    }
    a /= 10;
  }
  return false;
}
void go(int p, int v) {
  if (p == divs.size()) {
    if (try_a(v)) {
      k++;
    }
  } else {
    go(p + 1, v);
    for (int i = 0; i < pows[p]; i++) {
      v *= divs[p];
      go(p + 1, v);
    }
  }
}
void make_divs(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (!(n % i)) {
      int p = 0;
      divs.push_back(i);
      while (!(n % i)) {
        n /= i;
        p++;
      }
      pows.push_back(p);
    }
  }
  if (n > 1) {
    divs.push_back(n);
    pows.push_back(1);
  }
}
int main() {
  cin >> n;
  make_divs(n);
  while (n > 0) {
    dig[n % 10] = true;
    n /= 10;
  }
  go(0, 1);
  cout << k << "\n";
  return 0;
}
