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;
vector<long long> v;
void fact(long long n) {
  if (n == 1) {
    v.push_back(n);
    return;
  } else if (n >= 2) {
    v.push_back(n);
    v.push_back(1);
  }
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if ((n / i) != i) v.push_back(n / i);
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  fact(n);
  int ara[10];
  memset(ara, 0, sizeof(ara));
  long long m = n;
  while (m) {
    ara[m % 10]++;
    m /= 10;
  }
  long long cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    long long d = v[i];
    while (d) {
      if (ara[d % 10] != 0) {
        cnt++;
        break;
      }
      d /= 10;
    }
  }
  cout << cnt << '\n';
  return 0;
}
