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>
int S[10];
void init(unsigned int n) {
  int i;
  for (i = 0; i < 10; i++) S[i] = 0;
  while (n) {
    i = n % 10;
    n = n / 10;
    S[i] = 1;
  }
}
unsigned int deci(unsigned int n) {
  int i;
  while (n) {
    i = n % 10;
    n = n / 10;
    if (S[i]) return 1;
  }
  return 0;
}
int main() {
  unsigned int x;
  scanf("%u", &x);
  init(x);
  unsigned int stop = (unsigned int)sqrt((double)x);
  unsigned int i, ans = 0;
  for (i = 1; i <= stop; i++) {
    if (x % i) continue;
    ans += deci(i);
    unsigned int j = x / i;
    if (i != j) ans += deci(j);
  }
  printf("%u", ans);
  return 0;
}
