#include <bits/stdc++.h>
using namespace std;
const int N = 21000;
int pos[50], dp[15][100][12][12], st, vis[20];
void solve(int x) {
  while (x) {
    vis[x % 10] = 1;
    x /= 10;
  }
  return;
}
int get(int x) {
  while (x) {
    if (vis[x % 10] == 1) return 1;
    x /= 10;
  }
  return 0;
}
int main() {
  memset(vis, 0, sizeof(vis));
  int x, num = 0;
  scanf("%d", &x);
  solve(x);
  int k = (int)sqrt(x * 1.0);
  for (int i = 1; i <= k; i++) {
    if (x % i == 0) {
      if (get(i)) num++;
      if (x / i != i && get(x / i)) num++;
    }
  }
  printf("%d\n", num);
  return 0;
}
