#include <bits/stdc++.h>
using namespace std;
long n, m;
string s = "";
long same(long x, long y) {
  long i, j;
  while (x > 0) {
    i = x % 10;
    char a = i + '0';
    for (j = 0; j < s.size(); j++)
      if (s[j] == a) return 1;
    x /= 10;
  }
  return 0;
}
int main() {
  cin >> n;
  long i, j, k;
  i = n;
  while (i > 0) {
    j = i % 10;
    s = char(j + '0') + s;
    i /= 10;
  }
  long cnt = 0;
  for (i = 1; i <= sqrt(n); i++)
    if (n % i == 0) {
      if (same(i, n)) cnt++;
      j = n / i;
      if (j == i) continue;
      if (same(j, n)) cnt++;
    }
  cout << cnt;
}
