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;
int main() {
  long long n;
  cin >> n;
  int res = 1;
  set<long long> dgts;
  vector<long long> arr;
  long long bx = n;
  if (n == 1)
    res = 1;
  else {
    for (int i = 1; i <= sqrt(n) || bx > 0; i++) {
      if (n % i == 0 && i <= sqrt(n)) {
        arr.push_back(i);
        if (n / i > sqrt(n) && i != 1 && n != i) arr.push_back(n / i);
      }
      if (bx > 0) {
        int chk = 0;
        if (dgts.find(bx % 10) != dgts.end()) chk = 1;
        if (chk == 0) dgts.insert(bx % 10);
        bx /= 10;
      }
    }
    for (int i = 0; i < arr.size(); i++) {
      long long box = arr[i];
      while (box > 0) {
        int dgt = box % 10;
        if (dgts.find(dgt) != dgts.end()) {
          res++;
          break;
        }
        box /= 10;
      }
    }
  }
  cout << res;
  return 0;
}
