#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
vector<pair<int, int> > divs;
set<int> ans;
bool digits[10];
bool test(int n) {
  while (n) {
    if (digits[n % 10]) return true;
    n /= 10;
  }
  return false;
}
void rec(int div, int curr) {
  if (curr == ((int)divs.size())) {
    if (test(div)) ans.insert(div);
    return;
  }
  int mul = 1;
  for (int i = 0; i < (int)(divs[curr].second + 1); i++) {
    rec(div * mul, curr + 1);
    mul *= divs[curr].first;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int x, t;
  cin >> x;
  t = x;
  for (int i = 2; i * i <= t; i++) {
    if (t % i == 0) {
      divs.push_back(make_pair(i, 0));
      while (t % i == 0) {
        divs[((int)divs.size()) - 1].second++;
        t /= i;
      }
    }
  }
  if (t != 1) divs.push_back(make_pair(t, 1));
  t = x;
  while (t) {
    digits[t % 10] = true;
    t /= 10;
  }
  rec(1, 0);
  cout << ((int)ans.size()) << endl;
  return 0;
}
