#include <bits/stdc++.h>
using namespace std;
int get(int first, int second) {
  vector<int> d(10);
  while (first) {
    d[first % 10] = 1;
    first /= 10;
  }
  while (second) {
    if (d[second % 10] == 1) {
      return 1;
    }
    second /= 10;
  }
  return 0;
}
void solve() {
  int first;
  cin >> first;
  int ans = 0;
  for (int i = 1; i * i <= first; ++i) {
    if (first % i == 0) {
      ans += get(first, i);
      if (first / i != i) {
        ans += get(first, first / i);
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
