#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int mas[10];
  for (int i = 0; i < 10; i++) {
    mas[i] = 0;
  }
  int x_2 = x;
  while (x_2 > 0) {
    mas[x_2 % 10]++;
    x_2 /= 10;
  }
  int answer_count = 0;
  int q = 0;
  for (int i = 1; (i * i) <= x; i++) {
    if (x % i == 0) {
      int i_2 = i;
      while (i_2 > 0) {
        int number = i_2 % 10;
        if (mas[number] > 0) {
          answer_count++;
          break;
        }
        i_2 /= 10;
      }
      i_2 = i * i;
      if (x != i_2) {
        i_2 = x / i;
        while (i_2 > 0) {
          int number = i_2 % 10;
          if (mas[number] > 0) {
            answer_count++;
            break;
          }
          i_2 /= 10;
        }
      }
    }
  }
  cout << answer_count << endl;
  return 0;
}
