#include <bits/stdc++.h>
using namespace std;
int vis[10];
bool judge(int x) {
  while (x > 0) {
    if (vis[x % 10]) return true;
    x /= 10;
  }
  return false;
}
int main() {
  int x;
  scanf("%d", &x);
  int ans = 0;
  memset(vis, false, sizeof(vis));
  for (int y = x; y > 0; y /= 10) vis[y % 10] = true;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if (judge(i)) ans++;
      if (x / i != i && judge(x / i)) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
