#include <bits/stdc++.h>
using namespace std;
int b[100001];
int pan(int x) {
  while (x) {
    int t = x % 10;
    if (b[t] == 1) return 1;
    x /= 10;
  }
  return 0;
}
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  int x = read(), s = 0;
  int j = x;
  while (j) {
    b[j % 10] = 1;
    j /= 10;
  }
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      if (pan(i) == 1) ++s;
    }
  }
  for (int i = 1; i < sqrt(x); i++) {
    if (x % i == 0) {
      if (pan(x / i) == 1) ++s;
    }
  }
  write(s);
  return 0;
}
