#include <bits/stdc++.h>
using namespace std;
vector<int> v;
map<int, int> M;
int visit[10];
int main() {
  int i, j, n, p, q, ans;
  while (cin >> n) {
    M.clear();
    ans = 0;
    for (i = 0; i <= 9; i++) {
      visit[i] = 0;
    }
    q = n;
    while (q != 0) {
      visit[q % 10] = 1;
      q /= 10;
    }
    for (i = 1; i <= sqrt(n) + 1; i++) {
      if (!(n % i)) {
        p = i;
        q = n / i;
        if (!M[p]) {
          M[p] = 1;
          while (p != 0) {
            int a = p % 10;
            if (visit[a]) {
              ans++;
              break;
            }
            p /= 10;
          }
        }
        if (!M[q]) {
          M[q] = 1;
          while (q != 0) {
            int a = q % 10;
            if (visit[a]) {
              ans++;
              break;
            }
            q /= 10;
          }
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
