#include <bits/stdc++.h>
int main() {
  int num;
  int count = 0, i;
  int digitos[10];
  scanf("%d", &num);
  int aux = num;
  for (i = 0; i < 10; i++) digitos[i] = 0;
  while (aux != 0) {
    digitos[aux % 10] = 1;
    aux = aux / 10;
  }
  if (num == 1) {
    printf("1\n");
    return 0;
  }
  for (i = 1; i * i <= num; i++) {
    if (num % i == 0) {
      aux = i;
      while (aux != 0) {
        if (digitos[aux % 10] == 1) {
          count++;
          break;
        }
        aux = aux / 10;
      }
      aux = num / i;
      if (aux != i)
        while (aux != 0) {
          if (digitos[aux % 10] == 1) {
            count++;
            break;
          }
          aux = aux / 10;
        }
    }
  }
  printf("%d\n", count);
  return 0;
}
