#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8;
const int MAXR = 1;
const int MAXC = 1;
const int MAXBITS = 64;
const int INF = (int)1e9;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
priority_queue<int, vector<int>, greater<int>> q1;
priority_queue<int, vector<int>, less<int>> q2;
void l() { ; }
int arr[MAXN];
set<int> s;
void gd(int x) {
  while (x != 0) {
    s.insert(x % 10);
    x = x / 10;
  }
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int cnt = 0;
  gd(n);
  ;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      int d1 = i;
      int d2 = n / i;
      ;
      ;
      while (d1 != 0) {
        int z = d1 % 10;
        if (s.find(z) != s.end()) {
          cnt++;
          break;
        }
        d1 = d1 / 10;
      }
      if (d1 == d2) {
        continue;
      }
      while (d2 != 0) {
        int z = d2 % 10;
        if (s.find(z) != s.end()) {
          cnt++;
          break;
        }
        d2 = d2 / 10;
      }
    }
  }
  cout << cnt;
  return 0;
}
