#include <bits/stdc++.h>
using namespace std;
int arr[10];
int check(long long num) {
  while (num) {
    long long d = num % 10;
    num = num / 10;
    if (arr[d]) return 1;
  }
  return 0;
}
int main() {
  long long x;
  cin >> x;
  long long temp = x;
  for (int i = 0; i <= 9; i++) arr[i] = 0;
  while (temp) {
    long long d = temp % 10;
    arr[d] = 1;
    temp = temp / 10;
  }
  long long count = 0;
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0 && check(i)) {
      count++;
    }
    long long other = x / i;
    if (other != i && x % other == 0 && check(other)) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
