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;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
vector<int> digits(10, 0);
bool check_digits(int n) {
  while (n) {
    int dig = n % 10;
    n /= 10;
    if (digits[dig] > 0) {
      return true;
    }
  }
  return false;
}
int main() {
  int x;
  cin >> x;
  int cp = x;
  while (cp) {
    int dig = cp % 10;
    cp /= 10;
    digits[dig]++;
  }
  int fac = 1;
  int max_poss = sqrt(x);
  int ans = 0;
  while (fac <= max_poss) {
    if (x % fac == 0) {
      if (check_digits(fac)) {
        ans++;
      }
      if (check_digits(x / fac) && fac != x / fac) {
        ans++;
      }
    }
    fac++;
  }
  cout << ans;
  return 0;
}
