#include <bits/stdc++.h>
using namespace std;
bool mark[20], flag[20];
int ans;
bool valid(int x) {
  for (int i = 0; i < 10; i++) flag[i] = false;
  while (x > 0) {
    flag[x % 10] = true;
    x /= 10;
  }
  for (int i = 0; i < 10; i++)
    if (mark[i] && flag[i]) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  int m = n;
  while (n > 0) {
    mark[n % 10] = true;
    n /= 10;
  }
  for (int i = 1; i <= sqrt(m); i++) {
    if (m % i == 0) {
      if (valid(i)) ans++;
      if (valid(m / i) && m / i != i) ans++;
    }
  }
  cout << ans << "\n";
}
