#include <bits/stdc++.h>
using namespace std;
int x;
vector<short int> c;
bool si[10];
int l;
int e;
bool prova(int i) {
  int r = i;
  while (r > 0) {
    int b = r % 10;
    r /= 10;
    if (si[b]) return true;
  }
  return false;
}
int main() {
  cin >> x;
  int t = x;
  while (t > 0) {
    int a = t % 10;
    t /= 10;
    si[a] = true;
    c.push_back(a);
  }
  l = c.size();
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i != 0) continue;
    if (prova(i)) e++;
    if (x / i != i and prova(x / i)) e++;
  }
  cout << e;
}
