#include <bits/stdc++.h>
using namespace std;
char basic[15];
char cur[15];
int main() {
  int n;
  scanf("%d", &n);
  int t = n, j = 0;
  int result = 0;
  while (t > 0) {
    basic[j++] = t % 10 + '0';
    t /= 10;
  }
  basic[j++] = '\0';
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  int up_to = (int)floor(sqrt((double)n));
  for (int i = 1; i <= up_to; ++i) {
    if (n % i == 0) {
      int t = i, j = 0;
      ;
      while (t > 0) {
        cur[j++] = t % 10 + '0';
        t /= 10;
      }
      cur[j++] = '\0';
      if (strpbrk(basic, cur)) result++;
      if (n / i != i) {
        t = n / i;
        j = 0;
        while (t > 0) {
          cur[j++] = t % 10 + '0';
          t /= 10;
        }
        cur[j++] = '\0';
        if (strpbrk(basic, cur)) result++;
      }
    }
  }
  printf("%d\n", result);
  return 0;
}
