#include <bits/stdc++.h>
#pragma comment(linker, "/stack:100000000")
using namespace std;
bool u[10];
bool F(int x) {
  while (x != 0) {
    if (u[x % 10]) {
      return 1;
    }
    x /= 10;
  }
  return 0;
}
int main() {
  int x, res = 0;
  scanf("%d", &x);
  int y = x;
  while (y != 0) {
    u[y % 10] = 1;
    y /= 10;
  }
  for (int i = 1; i * i <= x; i++) {
    if (x % i != 0) continue;
    if (F(i)) ++res;
    if (i * i != x && F(x / i)) ++res;
  }
  printf("%d\n", res);
  return 0;
}
