#include <bits/stdc++.h>
int main() {
  int num[10], i, x, ans, tmp, flag, root;
  while (scanf("%d", &x) != EOF) {
    memset(num, 0, sizeof(num));
    for (tmp = x; tmp; tmp /= 10) num[tmp % 10] = 1;
    root = (int)sqrt(x);
    ans = 0;
    for (i = 1; i <= root; ++i)
      if (x % i == 0) {
        flag = 0;
        for (tmp = i; tmp; tmp /= 10)
          if (num[tmp % 10] == 1) {
            flag = 1;
            break;
          }
        if (flag == 1) ++ans;
        if (i * i == x) break;
        flag = 0;
        for (tmp = x / i; tmp; tmp /= 10)
          if (num[tmp % 10] == 1) {
            flag = 1;
            break;
          }
        if (flag == 1) ++ans;
      }
    printf("%d\n", ans);
  }
  return 0;
}
