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<int> dn(10);
vector<int> cdn(int a) {
  vector<int> tdn(10, 0);
  while (a) {
    tdn[a % 10] += 1;
    a /= 10;
  }
  return tdn;
}
bool comparecdn(int n, int i) {
  vector<int> idn = cdn(i);
  int sum = 0;
  for (long long(i) = 0; (i) < (10); (i)++) {
    sum += dn[i] && idn[i];
  }
  if (sum > 0)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  dn = cdn(n);
  vector<int> d;
  int cnt = 0;
  int x = ceil(sqrt(n));
  d.push_back(1);
  for (int i = 2; i <= x && i < n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      if (i != x) d.push_back(n / i);
    }
  }
  for (long long(i) = 0; (i) < (d.size()); (i)++) {
    if (comparecdn(n, d[i])) cnt += 1;
  }
  if (n > 1) cnt += 1;
  cout << cnt << endl;
  return 0;
}
