#include <bits/stdc++.h>
using namespace std;
int n;
int flag[10];
int chk(int x) {
  while (x > 0) {
    if (flag[x % 10] == 1) return 1;
    x /= 10;
  }
  return 0;
}
int main() {
  int t;
  cin >> n;
  for (int(i) = 0; (i) < (10); (i)++) flag[i] = 0;
  int cop = n;
  while (cop > 0) {
    int dig = cop % 10;
    flag[dig] = 1;
    cop /= 10;
  }
  int lim = sqrt(n);
  int ans = 0;
  for (int i = 1; i <= lim; i++) {
    if (n % i == 0) {
      if (chk(i)) {
        ans++;
      }
      if ((i != n / i) && chk(n / i)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
