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>
const int MOD = 1E9 + 7;
const int N = 1000 + 5;
const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
using namespace std;
int a[N];
void getBit(int temp) {
  while (temp) {
    a[temp % 10] = 1;
    temp /= 10;
  }
}
bool judge(int temp) {
  while (temp) {
    if (a[temp % 10]) return true;
    temp /= 10;
  }
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  getBit(n);
  int res = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (judge(i)) res++;
      if (judge(n / i)) res++;
    }
  }
  if (n == (int)sqrt(n) * (int)sqrt(n))
    if (judge((int)sqrt(n))) res--;
  printf("%d\n", res);
  return 0;
}
