#include <bits/stdc++.h>
using namespace std;
int counter = 0;
int x;
void Check(int i) {
  int y;
  int j = i;
  do {
    y = x;
    int ost = j % 10;
    do {
      if (y % 10 == ost) {
        counter++;
        return;
      }
      y /= 10;
    } while (y != 0);
    j /= 10;
  } while (j != 0);
}
int main() {
  cin >> x;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      Check(i);
      if (i * i != x) Check(x / i);
    }
  }
  cout << counter;
}
