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 v[10];
int simil(long long num1, int num2) {
  memset(v, 0, sizeof(v));
  while (num2 > 0) {
    v[num2 % 10] = 1;
    num2 /= 10;
  }
  while (num1 > 0) {
    if (v[num1 % 10] == 1) return 1;
    num1 /= 10;
  }
  return 0;
}
int fn(long long n) {
  if (n == 1) return 1;
  if (n == 2) return 1;
  int cnt = 0;
  int i = 1;
  while (i * i < n) {
    if (n % i == 0) {
      cnt += simil(n, i);
      cnt += simil(n, n / i);
    }
    i++;
  }
  if (n % i == 0) {
    cnt += simil(n, i);
  }
  return cnt;
}
int main() {
  long long n;
  while (cin >> n) cout << fn(n) << endl;
}
