#include <bits/stdc++.h>
using namespace std;
bool isOK(int x, bool *dig) {
  while (x) {
    if (dig[x % 10]) return 1;
    x /= 10;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    puts("1");
    return 0;
  }
  bool dig[10] = {0};
  int np = n;
  while (np) {
    dig[np % 10] = 1;
    np /= 10;
  }
  int cnt = 0;
  for (int i = 1; i <= (int)sqrt(n); ++i)
    if (n % i == 0) {
      if (isOK(i, dig)) cnt++;
      if (i * i != n && isOK(n / i, dig)) cnt++;
    }
  printf("%d\n", cnt);
  return 0;
}
