#include <bits/stdc++.h>
using namespace std;
bool check(int d, vector<bool>& digits) {
  while (d) {
    if (digits[d % 10]) return true;
    d /= 10;
  }
  return false;
}
int main() {
  int x, xx, res = 0;
  vector<int> div;
  vector<bool> digits(10, false);
  cin >> x;
  xx = x;
  while (xx) {
    digits[xx % 10] = true;
    xx /= 10;
  }
  for (int d = 1; d * d <= x; ++d) {
    if (x % d) continue;
    if (check(d, digits)) res++;
    if (d != (x / d) && check(x / d, digits)) res++;
  }
  cout << res << endl;
  return 0;
}
