#include <bits/stdc++.h>
char a[20], b[20];
bool match(int n, int i) {
  int i1, j;
  sprintf(a, "%d\0", n);
  sprintf(b, "%d\0", i);
  for (i1 = 0; a[i1] != '\0'; i1++) {
    for (j = 0; b[j] != '\0'; j++) {
      if (a[i1] == b[j]) {
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int n, i, j, count;
  scanf("%d", &n);
  ;
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  count = 0;
  for (i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (match(n, i)) {
        count++;
      }
      j = n / i;
      if (j != i && match(n, j)) {
        count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
