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 main() {
  int x, i = 1, k, j = 1, l, cnt = 0;
  scanf("%d", &x);
  int p[100000], q[100];
  for (k = 1; k <= sqrt(x); k++) {
    if (x % k == 0) {
      p[i++] = k;
      p[i++] = x / k;
    }
  }
  if (p[i - 2] == p[i - 1]) i = i - 1;
  while (x > 0) {
    q[j++] = x % 10;
    x = x / 10;
  }
  int m, t, tmp = 0;
  for (k = 1; k < i; k++) {
    while (p[k] > 0) {
      tmp = 0;
      t = p[k] % 10;
      for (m = 1; m < j; m++) {
        if (t == q[m]) {
          cnt++;
          tmp++;
          break;
        }
      }
      if (tmp == 1) break;
      p[k] = p[k] / 10;
    }
  }
  printf("%d", cnt);
  return 0;
}
