#include <bits/stdc++.h>
using namespace std;
bool digitos[10];
void pasarArray(int n) {
  while (n) {
    digitos[n % 10] = true;
    n /= 10;
  }
}
bool machea(int n) {
  while (n) {
    if (digitos[n % 10]) {
      return true;
    }
    n /= 10;
  }
  return false;
}
int main() {
  int x;
  cin >> x;
  pasarArray(x);
  int cont = 0;
  for (int i = 1; i <= (int)sqrt(x); i++) {
    if (x % i == 0) {
      if (machea(i)) cont++;
      if (i != x / i && machea(x / i)) cont++;
    }
  }
  cout << cont << endl;
}
