#include <bits/stdc++.h>
using namespace std;
set<int> S;
bool found(int n) {
  while (n) {
    if (S.find(n % 10) != S.end()) {
      return true;
    }
    n /= 10;
  }
  return false;
}
int solve(int n) {
  int c = 0, temp = n;
  while (temp) S.insert(temp % 10), temp /= 10;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (found(i)) c++;
      if (n / i != i && found(n / i)) c++;
    }
  }
  return c;
}
int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", solve(n));
  return 0;
}
