#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  set<int> a1;
  set<int>::iterator it1;
  set<int> ans;
  set<int>::iterator it;
  int N = n;
  while (N) {
    a1.insert(N % 10);
    N = N / 10;
  }
  for (i = 1; i <= sqrt(n) + 1; i++) {
    if (n % i == 0) {
      ans.insert(i);
      ans.insert(n / i);
    }
  }
  int cnt = 0;
  for (it = ans.begin(); it != ans.end(); ++it) {
    int d = *it;
    int flag = 0;
    while (d > 0) {
      it1 = a1.find(d % 10);
      if (it1 != a1.end()) {
        flag = 1;
        break;
      }
      d = d / 10;
    }
    if (flag == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
