#include <bits/stdc++.h>
const long long mod = 1000000007;
const double PI = 3.14159265358979323846;
using namespace std;
vector<bool> m(10, 0);
bool match(long long num, long long x) {
  while (num > 0) {
    if (m[num % 10] > 0) return true;
    num /= 10;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    long long x;
    cin >> x;
    long long temp = x;
    while (temp > 0) {
      m[temp % 10] = 1;
      temp /= 10;
    }
    long long ans = 0;
    for (long long i = 1; i <= sqrt(x); i++) {
      if (x % i == 0) {
        if (match(i, x)) ans++;
        if (x / i != i && match(x / i, x)) ans++;
      }
    }
    cout << ans;
  }
}
