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 int oo = 0x3f3f3f3f;
const double eps = 1e-9;
int TC;
bool check(int a, int b) {
  set<int> s;
  while (a > 0) {
    s.insert(a % 10);
    a /= 10;
  }
  while (b > 0) {
    if (s.find(b % 10) != s.end()) return true;
    b /= 10;
  }
  return false;
}
int main() {
  int N;
  cin >> N;
  int res = 0;
  for (int i = (1); i < (N + 1); i++) {
    if (i * i > N) break;
    if (N % i == 0) {
      if (check(N, i)) ++res;
      int o = N / i;
      if (o > i)
        if (check(N, o)) ++res;
    }
  }
  cout << res;
  return 0;
}
