#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MAX = 100005;
bool check(int x, int y) {
  int cnt1[11] = {0};
  int cnt2[11] = {0};
  while (x > 0) {
    cnt1[x % 10]++;
    x /= 10;
  }
  while (y > 0) {
    cnt2[y % 10]++;
    y /= 10;
  }
  for (int i = 0; i < 10; i++) {
    if (cnt1[i] > 0 and cnt2[i] > 0) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  vector<int> v;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if (i * i == x)
        v.push_back(i);
      else
        v.push_back(i), v.push_back(x / i);
    }
  }
  int ans = 0, sz = v.size();
  for (int i = 0; i < sz; i++) {
    if (check(x, v[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}
