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;
const long long OO = (long long)1e15;
vector<long long> v1;
map<long long, long long> ma;
bool fu(long long n, long long m) {
  int i, j;
  stringstream s1, s2;
  s1 << n;
  s2 << m;
  string x = s1.str(), y = s2.str();
  for (i = 0; i < x.size(); i++) {
    for (j = 0; j < y.size(); j++) {
      if (x[i] == y[j]) {
        return true;
      }
    }
  }
  return false;
}
long long f(long long n) {
  long long i, c = 0;
  for (i = 1; i * i <= n; i++) {
    if (i * i == n) {
      if (fu(n, i)) {
        c++;
      }
    } else if (n % i == 0) {
      if (fu(n, i)) {
        c++;
      }
      if (fu(n, n / i)) {
        c++;
      }
    }
  }
  return c;
}
int main() {
  long long n;
  cin >> n;
  cout << f(n);
  return 0;
}
