The Little Elephant loves numbers. 

He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. 

Help the Little Elephant to find the described number.

Input

A single line contains a single integer x (1 ≤ x ≤ 109).

Output

In a single line print an integer — the answer to the problem.

Examples

Input

1


Output

1


Input

10


Output

2
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
bool sortinrev(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return (a.first > b.first);
}
long long int A[1000000];
long long int B[1000000];
vector<long long int> v, help;
bool fun() {
  for (long long int i = 0; i < help.size(); i++) {
    for (long long int j = 0; j < v.size(); j++) {
      if (help[i] == v[j]) return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, val, res = 0;
  cin >> n;
  val = n;
  while (val != 0) v.push_back(val % 10), val /= 10;
  sort(v.begin(), v.end());
  for (long long int i = 1; (i * i) <= n; i++) {
    if (n % i == 0) {
      if (n / i == i) {
        long long int a = i;
        while (a != 0) help.push_back(a % 10), a /= 10;
        if (fun()) res++;
        help.clear();
      } else {
        long long int a = i, b = n / i;
        while (a != 0) help.push_back(a % 10), a /= 10;
        if (fun()) res++;
        help.clear();
        while (b != 0) help.push_back(b % 10), b /= 10;
        if (fun()) res++;
        help.clear();
      }
    }
  }
  cout << res << endl;
  return 0;
}
