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 a, j, i, total;
bool b[15], cek;
queue<int> q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a;
  j = a;
  while (j > 0) {
    b[j % 10] = true;
    j /= 10;
  }
  q.push(a);
  if (q.front() != 1) q.push(1);
  for (i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      q.push(i);
      if (i != a / i) q.push(a / i);
    }
  }
  while (q.size() != 0) {
    j = q.front();
    q.pop();
    cek = false;
    while (j > 0) {
      if (b[j % 10] == true) {
        cek = true;
        break;
      }
      j /= 10;
    }
    if (cek == true) total++;
  }
  cout << total << "\n";
}
