#include <bits/stdc++.h>
using namespace std;
set<int> S;
bool judge(int n) {
  while (n != 0) {
    if (S.find(n % 10) != S.end())
      return (true);
    else
      n /= 10;
  }
  return (false);
}
int main() {
  int n, i;
  while (~scanf("%d", &n)) {
    if (n == 1) {
      printf("1\n");
      continue;
    }
    int ans = 0, rt = n;
    S.clear();
    while (rt != 0) {
      S.insert(rt % 10);
      rt /= 10;
    }
    for (i = 1; i <= sqrt(n); ++i) {
      if (n % i == 0) {
        if (judge(i)) ++ans;
        if ((n / i != i) && judge(n / i)) ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
