#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 1e5 + 7;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {2, 2, 1, -1, -2, -2, -1, 1};
const int dy[] = {1, -1, -2, -2, -1, 1, 2, 2};
void solve() {
  long long n;
  cin >> n;
  long long t = n;
  set<int> dig;
  set<long long> ans;
  while (t) {
    int x = t % 10;
    dig.insert(x);
    t /= 10;
  }
  for (int i = 1; i < sqrt(double(n)) + 1; ++i)
    if (n % i == 0) {
      long long div = n / i;
      t = i;
      int total = 0, bad = 0;
      while (t) {
        ++total;
        int x = t % 10;
        if (dig.find(x) == dig.end()) ++bad;
        t /= 10;
      }
      if (total - bad) ans.insert(i);
      total = bad = 0;
      while (div) {
        ++total;
        int x = div % 10;
        if (dig.find(x) == dig.end()) ++bad;
        div /= 10;
      }
      if (total - bad) ans.insert(n / i);
    }
  cout << ans.size() << endl;
}
int main() {
  solve();
  return 0;
}
