#include <bits/stdc++.h>
int n;
int has[10];
int mcmp(int b) {
  while (b > 0) {
    int x = b % 10;
    if (has[x] == 1) {
      return 1;
    }
    b = b / 10;
  }
  return 0;
}
int main() {
  memset(has, 0, sizeof(has));
  scanf("%d", &n);
  int t = n;
  while (t > 0) {
    int x = t % 10;
    has[x] = 1;
    t = t / 10;
  }
  int sqn = (int)ceil(sqrt(double(n)));
  int ans = 0;
  for (int i = 1; i < sqn; i++)
    if (n % i == 0) {
      ans += mcmp(i);
      ans += mcmp(n / i);
    }
  if (n % sqn == 0 && n != sqn || n == 1) ans += mcmp(sqn);
  printf("%d\n", ans);
  return 0;
}
