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>
int adad[15];
int yorn(int a) {
  while (a) {
    for (int k = 0; adad[k] != -1; k++) {
      if (a % 10 == adad[k]) {
        return 1;
      }
    }
    a /= 10;
  }
  return 0;
}
using namespace std;
int main() {
  int count = 0;
  int temp;
  long long int fun;
  double funf;
  int ghadim;
  long long int yechizi;
  int jadid;
  memset(adad, -1, sizeof(adad));
  cin >> fun;
  funf = fun;
  temp = int(sqrt(funf));
  yechizi = fun;
  for (int i = 0; fun; i++) {
    adad[i] = fun % 10;
    fun /= 10;
  }
  for (int i = 1; i <= temp; i++) {
    jadid = i;
    if (yechizi % jadid == 0) {
      ghadim = yechizi / jadid;
      count += yorn(jadid);
      if (ghadim != jadid) count += yorn(ghadim);
    }
  }
  cout << count << endl;
}
