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>
using namespace std;
int F(long long A, long long B) {
  vector<int> M, N;
  while (A != 0) {
    M.push_back(A % 10);
    A /= 10;
  }
  while (B != 0) {
    N.push_back(B % 10);
    B /= 10;
  }
  int i, j;
  for (i = 00; i < M.size(); i++) {
    for (j = 00; j < N.size(); j++)
      if (M[i] == N[j]) return 1;
  }
  return 0;
}
int main() {
  int i, x, ans = 0;
  cin >> x;
  vector<int> Fac;
  for (i = 1; i <= sqrt(x); i++)
    if (i * (x / i) == x) {
      Fac.push_back(i);
      if (i != x / i) Fac.push_back(x / i);
    }
  for (i = 0; i < Fac.size(); i++) {
    if (x % Fac[i] == 0) {
      if (F(x, Fac[i])) ans++;
    }
  }
  cout << ans;
  return 0;
}
