#include <bits/stdc++.h>
using namespace std;
int dig[11], ans, len;
void f(long long n) {
  len = 0;
  while (n) {
    dig[++len] = n % 10;
    n /= 10;
  }
}
void judge(int x) {
  bool f = 0;
  while (x) {
    int xx = x % 10;
    for (int i = 1; i <= len; i++) {
      if (xx == dig[i]) {
        ans++;
        f = 1;
        break;
      }
    }
    x /= 10;
    if (f == 1) break;
  }
}
int main() {
  long long n;
  cin >> n;
  f(n);
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      judge(i);
      if (i * i != n) {
        judge(n / i);
      }
    }
  }
  cout << ans << endl;
}
