#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) {
  return {l.first + r.first, l.second + r.second};
}
typedef void (*callback_function)(void);
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const long double PI = acos(-1.0L);
const long double EPS = static_cast<long double>(1e-9);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  {
    int x;
    cin >> x;
    string s = to_string(x);
    set<char> st;
    for (char &c : s) st.insert(c);
    int sqrtX = sqrt(x), res = 0;
    for (int i = (1); i <= (sqrtX); i++)
      if (x % i == 0) {
        s = to_string(i);
        for (char &c : s)
          if (st.count(c)) {
            res++;
            break;
          }
        int j = x / i;
        if (j == i) break;
        s = to_string(x / i);
        for (char &c : s)
          if (st.count(c)) {
            res++;
            break;
          }
      }
    cout << res << endl;
  }
  return 0;
}
