#include <bits/stdc++.h>
using namespace std;
set<int> s;
bool judge(int a, int b) {
  int x[10010], y;
  int xx = 0;
  while (a) {
    x[++xx] = a % 10;
    a /= 10;
  }
  while (b) {
    y = b % 10;
    for (int i = 1; i <= xx; i++)
      if (x[i] == y) return true;
    b /= 10;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (judge(i, n)) s.insert(i);
      if (judge(n / i, n)) s.insert(n / i);
    }
  }
  cout << s.size() << endl;
}
