#include <bits/stdc++.h>
using namespace std;
const int N = 10 + 5;
int x;
bool freq[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> x;
  memset(freq, false, sizeof(freq));
  int tmp = x;
  while (tmp > 0) {
    freq[tmp % 10] = true;
    tmp /= 10;
  }
  int ans = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i != 0) continue;
    int tmp = i;
    while (tmp > 0) {
      if (freq[tmp % 10]) {
        ans++;
        break;
      }
      tmp /= 10;
    }
    if (x / i == i) continue;
    tmp = x / i;
    while (tmp > 0) {
      if (freq[tmp % 10]) {
        ans++;
        break;
      }
      tmp /= 10;
    }
  }
  cout << ans << '\n';
  return 0;
}
