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;
const double EPS = 1e-9;
const double INF = 0x7f7f7f7f;
double dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};
double dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};
double dr4[4] = {0, 0, 1, -1};
double dc4[4] = {-1, 1, 0, 0};
double kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};
double kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};
bool check_(long long a, long long b) {
  long long ar[12] = {0};
  while (a) {
    if (ar[a % 10] == 0) ar[a % 10]++;
    a = a / 10;
  }
  while (b) {
    if (ar[b % 10] == 1) return 1;
    b = b / 10;
  }
  return 0;
}
int main() {
  long long n, ans = 0;
  cin >> n;
  long long sq = sqrt(n);
  for (long long i = 1; i <= sq; i++) {
    if (n % i == 0) {
      if (check_(n, i)) ans++;
      if (i != (n / i) && check_(n, n / i)) ans++;
    }
  }
  cout << ans << "\n";
}
