#include <bits/stdc++.h>
using namespace std;
int m[11];
int dig(int i) {
  while (i) {
    if (m[i % 10]) return 1;
    i /= 10;
  }
  return 0;
}
int main() {
  int n, i, s(0);
  cin >> n;
  int temp = n;
  for (int i = 0; i < 11; i++) m[i] = 0;
  while (temp) {
    m[temp % 10] = 1;
    temp /= 10;
  }
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      s += dig(i);
      if (i != sqrt(n)) s += dig(n / i);
    }
  }
  cout << s << endl;
  return 0;
}
