#include <bits/stdc++.h>
using namespace std;
vector<int> na(10);
bool common(int n, int r) {
  int t1 = 0, sv;
  while (r) {
    na[t1++] = r % 10;
    r /= 10;
  }
  while (n) {
    sv = n % 10;
    for (int i = 0; i < (t1); ++i)
      if (na[i] == sv) return true;
    n /= 10;
  }
  return false;
}
int main() {
  int num, root, cnt = 0;
  cin >> num;
  root = (int)sqrt(num);
  for (int i = 1; i <= (root); ++i) {
    if (num % i == 0) {
      if (common(num, i)) ++cnt;
      if (num / i != i && common(num, num / i)) ++cnt;
    }
  }
  cout << (cnt) << endl;
  return 0;
}
