#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, a, b, count = 0;
  set<int> s;
  cin >> x;
  for (auto c : to_string(x)) s.insert(c);
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      a = i;
      b = x / i;
      for (auto c : to_string(a))
        if (s.find(c) != s.end()) {
          count++;
          break;
        }
      if (b != a)
        for (auto c : to_string(b))
          if (s.find(c) != s.end()) {
            count++;
            break;
          }
    }
  }
  cout << count;
  return 0;
}
