#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, n;
  int rem;
  cin >> x;
  set<int> s, v;
  set<int>::iterator itv;
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      v.insert(i);
      v.insert(x / i);
    }
  }
  int c = 0;
  n = x;
  while (n != 0) {
    rem = n % 10;
    n = n / 10;
    s.insert(rem);
  }
  for (itv = v.begin(); itv != v.end(); itv++) {
    n = *itv;
    while (n != 0) {
      rem = n % 10;
      n = n / 10;
      if (s.count(rem)) {
        c++;
        break;
      }
    }
  }
  cout << c;
  return 0;
}
