#include <bits/stdc++.h>
using namespace std;
bool a[10];
int check(long int x) {
  while (x) {
    if (a[x % 10]) {
      return 1;
    }
    x /= 10;
  }
  return 0;
}
int main() {
  long int x, n, ans = 0;
  cin >> n;
  x = n;
  while (x) {
    a[x % 10] = true;
    x /= 10;
  }
  for (long int i = 1; i * i <= n; i++) {
    if (!(n % i)) {
      ans += check(i);
      ans += check(n / i);
      if (i == n / i) {
        ans -= check(n / i);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
