#include <bits/stdc++.h>
using namespace std;
vector<int> v;
bool joos(int p) {
  for (int i = 0; i < v.size(); i++)
    if (v[i] == p) return true;
  return false;
}
int check(int a) {
  while (a != 0)
    if (joos(a % 10) == true)
      return 1;
    else
      a /= 10;
  return 0;
}
int main() {
  int n;
  cin >> n;
  int x = n;
  while (x != 0) {
    v.push_back(x % 10);
    x /= 10;
  }
  int cnt = 0;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      cnt += check(i);
      if (i != n / i) cnt += check(n / i);
    }
  cout << cnt << endl;
  return 0;
}
