#include <bits/stdc++.h>
using namespace std;
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (size_t i_ = 0; i_ < v.size(); ++i_) in >> v[i_];
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (size_t i_ = 0; i_ < v.size(); ++i_) out << v[i_] << ' ';
  out << endl;
  return out;
}
int j, k, m, i, n;
int a[20];
int func(int x) {
  while (x) {
    if (a[x % 10]) return 1;
    x /= 10;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  m = n;
  while (m) {
    a[m % 10] = 1;
    m /= 10;
  }
  for (i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      m = i;
      j += func(m);
      if (i * i != n) {
        m = n / i;
        j += func(m);
      }
    }
  }
  cout << j;
  return 0;
}
