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 fix(long long cur, long long m) { return ((cur % m) + m) % m; }
long long fast_power(long long x, long long y, long long m) {
  if (y == 0) return 1;
  long long temp = fast_power(x, y / 2, m);
  temp = (temp * temp) % m;
  if (y % 2 != 0) temp = (temp * x) % m;
  return temp;
}
vector<int> div(int x) {
  vector<int> ans;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if (i * i == x)
        ans.push_back(i);
      else {
        ans.push_back(i);
        ans.push_back(x / i);
      }
    }
  }
  return ans;
}
bool common(int a, int b) {
  while (a > 0) {
    int tmp = b;
    int a_digit = a % 10;
    while (tmp > 0) {
      int tmp_digit = tmp % 10;
      if (tmp_digit == a_digit) return true;
      tmp /= 10;
    }
    a /= 10;
  }
  return false;
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> divisors = div(n);
  int cnt = 0;
  for (int i = 0; i < divisors.size(); i++) {
    if (common(divisors[i], n)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
