#include <bits/stdc++.h>
using namespace std;
int n;
inline int f(int a) {
  int n1 = n;
  bool y = 0;
  while (n1 != 0) {
    int h = a;
    int u = n1 % 10;
    n1 = n1 / 10;
    while (h != 0) {
      int j = h % 10;
      h = h / 10;
      if (u == j) {
        y = 1;
        break;
      }
    }
  }
  return y;
}
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      int i2 = n / i;
      if (f(i) == 1) ans++;
      if (f(i2) == 1 && i2 != i) ans++;
    }
  }
  cout << ans << endl;
}
