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;
long long check(long long i, vector<long long> v) {
  while (i != 0) {
    if (v[i % 10] == 1) {
      return (1);
    }
    i = i / 10;
  }
  return (0);
}
long long divisors(long long n, vector<long long> v) {
  long long i, temp, j;
  j = 0;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (check(i, v)) {
        j++;
      }
      if (i != n / i) {
        if (check(n / i, v)) {
          j++;
        }
      }
    }
  }
  if (v[1] == 1) {
    j++;
  }
  if (check(n, v) && n != 1) {
    j++;
  }
  return (j);
}
int main() {
  vector<long long> v(10, 0);
  long long n, i;
  cin >> n;
  i = n;
  while (i != 0) {
    v[i % 10] = 1;
    i = i / 10;
  }
  i = divisors(n, v);
  cout << i;
  return 0;
}
