#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 1000000009;
double eps = 1e-12;
bool checkDigit(long long n1, long long n2) {
  long long a[10] = {0};
  while (n1) {
    if (a[n1 % 10] == 0) {
      a[n1 % 10]++;
    }
    n1 /= 10;
  }
  while (n2) {
    if (a[n2 % 10] == 1) return 1;
    n2 /= 10;
  }
  return 0;
}
void solve() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (checkDigit(n, i)) ans++;
      if (checkDigit(n, n / i) && i != n / i) ans++;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (int it = 1; it <= t; it++) {
    solve();
  }
  return 0;
}
