#include <bits/stdc++.h>
using namespace std;
int number[10];
int result = 0;
void judge(int i) {
  while (i != 0) {
    if (number[i % 10] == 1) {
      result++;
      break;
    }
    i = i / 10;
  }
}
int main() {
  int x, n, b = 0, i;
  for (i = 0; i < 10; i++) {
    number[i] = 0;
  }
  int tempn;
  cin >> tempn;
  n = tempn;
  while (n >= 1) {
    number[n % 10] = 1;
    n = n / 10;
  }
  if (tempn == 1) {
    result = 1;
  } else {
    for (i = 1; i * i <= tempn; i++) {
      if (tempn % i == 0) {
        judge(i);
        if (tempn / i != i) {
          judge(tempn / i);
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}
