#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10, inf = 0x3f3f3f3f, Mod = 1000000007;
int check(int num, int *vis) {
  while (num) {
    if (vis[num % 10]) {
      return 1;
    }
    num /= 10;
  }
  return 0;
}
int main() {
  int vis[10] = {0}, x, tmp;
  cin >> x;
  tmp = x;
  while (tmp) {
    vis[tmp % 10] = 1;
    tmp /= 10;
  }
  int ans = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      ans += check(i, vis);
      if (i != x / i) ans += check(x / i, vis);
    }
  }
  cout << ans << endl;
  return 0;
}
