#include <bits/stdc++.h>
using namespace std;
set<int> a;
int ans = 0;
void ces(int c) {
  while (c) {
    if (a.count(c % 10) == 1) {
      ans++;
      return;
    }
    c /= 10;
  }
}
int main() {
  int n = 0;
  cin >> n;
  int x = n;
  while (x) {
    a.insert(x % 10);
    x /= 10;
  }
  if (n == 1)
    cout << '1' << endl;
  else {
    for (int i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        ces(i);
        if (n / i != i) {
          ces(n / i);
        }
      }
    }
    cout << ans << endl;
  }
}
