#include <bits/stdc++.h>
using namespace std;
int fact(vector<int> x, long long t) {
  if (t == 1) return 1;
  vector<long long> num(x.begin(), x.end());
  stringstream s;
  string tmp;
  s << t;
  s >> tmp;
  int count = 0;
  for (int i = 0; i < num.size(); i++) {
    stringstream ss;
    string temp;
    ss << num[i];
    ss >> temp;
    bool flag = false;
    for (int j = 0; j < temp.size(); j++) {
      for (int k = 0; k < tmp.size(); k++)
        if (temp[j] == tmp[k]) {
          count++;
          flag = true;
          break;
        }
      if (flag) break;
    }
  }
  return count;
}
int main() {
  long long n;
  cin >> n;
  long long t = n;
  vector<int> factors;
  long long i;
  factors.push_back(1);
  for (i = 2; i < sqrt(n); i++) {
    if (n % i == 0) {
      factors.push_back(n / i);
      factors.push_back(i);
    }
  }
  if (i * i == n) {
    factors.push_back(i);
  }
  factors.push_back(n);
  cout << fact(factors, t);
  return 0;
}
