#include <bits/stdc++.h>
using namespace std;
vector<int> divisor(int a) {
  vector<int> res;
  for (int i = 1; i * i <= a; i++)
    if (a % i == 0) {
      res.push_back(i);
      if (i * i < a) res.push_back(a / i);
    }
  return res;
}
int main() {
  int x;
  scanf("%d", &x);
  vector<int> d = divisor(x);
  int ans = 0;
  for (int i = 0; i < (d.size()); i++) {
    char s[16], t[16];
    sprintf(s, "%d", x);
    sprintf(t, "%d", d[i]);
    bool ok = false;
    for (int i = 0; s[i]; i++)
      for (int j = 0; t[j]; j++)
        if (s[i] == t[j]) ok = true;
    if (ok) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
