#include <bits/stdc++.h>
using namespace std;
void find_Divisors(long long N, vector<long>& A) {
  for (long long i = 1; i < sqrt(N); i++)
    if (N % i == 0) A.push_back(i);
  for (long long i = sqrt(N); i > 0; i--)
    if (N % i == 0) A.push_back(N / i);
}
bool test(long n, long m) {
  string sn = to_string(n);
  string sm = to_string(m);
  for (int i = 0; i < sn.length(); i++)
    if (sm.find(sn[i]) != -1) return 1;
  return 0;
}
int main() {
  long n, count = 0;
  cin >> n;
  vector<long> div;
  find_Divisors(n, div);
  for (long i = 0; i < div.size(); i++) {
    count += test(n, div[i]);
  }
  cout << count;
  return 0;
}
