#include <bits/stdc++.h>
using namespace std;
bool vis[20];
int main() {
  int n;
  long long ans = 0;
  scanf("%d", &n);
  int tmp = n;
  while (tmp) {
    vis[tmp % 10] = true;
    tmp /= 10;
  }
  for (int i = 1; 1LL * i * i <= n; i++) {
    if (n % i != 0) continue;
    int tmp = i;
    bool ok = false;
    while (tmp) {
      if (vis[tmp % 10]) {
        ok = true;
        break;
      }
      tmp /= 10;
    }
    if (ok) ans++;
    tmp = n / i;
    if (tmp == i) continue;
    ok = false;
    while (tmp) {
      if (vis[tmp % 10]) {
        ok = true;
        break;
      }
      tmp /= 10;
    }
    if (ok) ans++;
  }
  printf("%I64d\n", ans);
}
