#include <bits/stdc++.h>
using namespace std;
int x, ans, mark[10];
int solve(int n) {
  int ret = 0;
  while (n) {
    if (mark[n % 10]) {
      ret++;
      break;
    }
    n /= 10;
  }
  return ret;
}
int main() {
  cin >> x;
  int temp = x;
  while (temp) {
    mark[temp % 10] = 1;
    temp /= 10;
  }
  for (int d = 1; d * d <= x; d++) {
    if (x % d == 0) {
      int number = solve(d);
      if (number > 0) {
        ans++;
      }
      int a = x / d;
      if (a * a != x) {
        number = solve(a);
        if (number > 0) {
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
