#include <bits/stdc++.h>
using namespace std;
int a[10];
void isop(int x) {
  while (x > 0) {
    a[x % 10]++;
    x /= 10;
  }
}
int d[10];
int main() {
  int n, i, j, cnt = 0, x;
  cin >> n;
  x = n;
  while (x > 0) {
    d[x % 10]++;
    x /= 10;
  }
  for (i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    bool ok = 0;
    for (j = 0; j <= 9; j++) a[j] = 0;
    isop(i);
    for (j = 0; j <= 9; j++) {
      if (d[j] && a[j]) ok = 1;
      a[j] = 0;
    }
    if (ok) cnt++;
    if (i * i == n) continue;
    ok = 0;
    isop(n / i);
    for (j = 0; j <= 9; j++) {
      if (d[j] && a[j]) ok = 1;
    }
    if (ok) cnt++;
  }
  cout << cnt;
}
