#include <bits/stdc++.h>
const int MAXN = 33;
int x;
int ar[MAXN];
int at;
bool look(int d) {
  int as[MAXN], ats = 0, i, j;
  while (d) as[++ats] = d % 10, d /= 10;
  for (i = 1; i <= ats; i++)
    for (j = 1; j <= at; j++)
      if (as[i] == ar[j]) return 1;
  return 0;
}
int main() {
  scanf(" %d", &x);
  int a = x;
  while (a) ar[++at] = a % 10, a /= 10;
  int i, cnt = 0;
  for (i = 1; i * i <= x; i++) {
    if (x % i) continue;
    if (x / i == i)
      cnt += look(i);
    else
      cnt += look(i) + look(x / i);
  }
  printf("%d\n", cnt);
  return 0;
}
