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 have[12];
int main() {
  int i, n, x, y, ans, m, flag;
  scanf("%d", &n);
  m = floor(sqrt(n));
  ans = 0;
  memset(have, 0, sizeof(have));
  x = n;
  while (x) {
    y = x % 10;
    have[y]++;
    x /= 10;
  }
  for (i = 1; i <= m; i++) {
    flag = false;
    if (n % i) continue;
    x = i;
    while (x) {
      y = x % 10;
      if (have[y]) flag = true;
      x /= 10;
    }
    if (flag) ans++;
    flag = false;
    x = n / i;
    if (n == i * i) continue;
    while (x) {
      y = x % 10;
      if (have[y]) flag = true;
      x /= 10;
    }
    if (flag) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
