#include <bits/stdc++.h>
using namespace std;
int d[15];
bool check(int a) {
  while (a > 0) {
    if (d[a % 10] > 0) return 1;
    a /= 10;
  }
  return 0;
}
int main() {
  int X;
  cin >> X;
  int t = X;
  while (t > 0) {
    d[t % 10]++;
    t /= 10;
  }
  double T = X;
  T = sqrt(T);
  int cnt = 0;
  if (X == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 1; i <= T; i++) {
    if (X % i == 0) {
      if (check(i)) cnt++;
      if (i * i != X && check(X / i)) cnt++;
    }
  }
  cout << cnt;
  return 0;
}
