#include <bits/stdc++.h>
using namespace std;
bool sameDigit(int a, int b) {
  int i = 0, a1[100], b1[100];
  while (a > 0) {
    a1[i] = a % 10;
    a /= 10;
    i++;
  }
  int j = 0;
  while (b > 0) {
    b1[j] = b % 10;
    b /= 10;
    j++;
  }
  for (int k = 0; k < i; k++)
    for (int l = 0; l < j; l++)
      if (a1[k] == b1[l]) return true;
  return false;
}
int main() {
  long long n;
  cin >> n;
  int a[10000];
  int j = 0;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a[j] = i;
      j++;
      if (i != n / i) {
        a[j] = n / i;
        j++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < j; i++)
    if (sameDigit(a[i], n)) ans++;
  cout << ans << endl;
  return 0;
}
