#include <bits/stdc++.h>
using namespace std;
bool yes(int a, int b, bool vis[10]) {
  long long int temp = a;
  while (temp > 0) {
    int r = temp % 10;
    if (vis[r] == true) {
      return true;
    }
    temp /= 10;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  bool vis[10];
  for (int i = 0; i <= 9; i++) {
    vis[i] = false;
  }
  long long int temp = n;
  while (n > 0) {
    int r = n % 10;
    vis[r] = true;
    n /= 10;
  }
  n = temp;
  long long int cnt = 0;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (yes(i, n, vis)) {
        cnt++;
      }
      if (i * i != n) {
        if (yes(n / i, n, vis)) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
}
