#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int y;
};
int Max(int x, int y) { return x > y ? x : y; }
int Min(int x, int y) { return x < y ? x : y; }
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
queue<int> Q;
stack<int> S;
int a, b, c;
int res, tmp;
int n, m;
bool flag[10], mark[10];
bool check(int x) {
  memset(flag, 0, sizeof(flag));
  memset(mark, 0, sizeof(mark));
  int nn = n;
  while (nn) {
    res = nn % 10;
    flag[res] = true;
    nn /= 10;
  }
  while (x) {
    res = x % 10;
    mark[res] = true;
    x /= 10;
  }
  int i;
  for (i = 0; i < 10; ++i)
    if (flag[i] && mark[i]) return true;
  return false;
}
int main() {
  int i, j;
  while (scanf("%d", &n) != EOF) {
    int cnt = 0;
    for (i = 1; i <= (int)sqrt(n * 1.0); ++i) {
      if (n % i == 0) {
        if (check(i)) ++cnt;
        if ((n / i) != i && check(n / i)) ++cnt;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
