#include <bits/stdc++.h>
using namespace std;
int n;
bool dig[10] = {false};
bool fun(int i) {
  while (i) {
    if (dig[i % 10]) return true;
    i /= 10;
  }
  return false;
}
int main() {
  cin >> n;
  int k = n, cnt = 0;
  while (k) {
    dig[k % 10] = true;
    k /= 10;
  }
  for (int i = 1; i <= n / 3; i++) {
    if (n % i == 0 && fun(i)) cnt++;
  }
  if (n % 2 == 0 && fun(n / 2)) cnt++;
  cout << cnt + 1 << endl;
  return 0;
}
