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 cif_x[11];
int x, cx;
int cif_d[11];
int sq(int x) {
  int a;
  for (a = 1; a * a <= x; a++)
    ;
  return a;
}
int cifra(int d) {
  int cd = 0;
  int i = 0, j = 0;
  while (d / 10 != 0) {
    cif_d[cd] = d % 10;
    d = d / 10;
    cd++;
  }
  cif_d[cd] = d;
  cd++;
  for (i = 0; i < cx; i++) {
    for (j = 0; j < cd; j++)
      if (cif_x[i] == cif_d[j]) return 1;
  }
  return 0;
}
int main() {
  int tx, d, ans, tmp;
  ans = 0;
  scanf("%d", &x);
  if (x == 1 || x == 2) {
    printf("1\n");
    return 0;
  }
  cx = 0;
  tx = x;
  while (tx / 10 != 0) {
    cif_x[cx] = tx % 10;
    tx = tx / 10;
    cx++;
  }
  cif_x[cx] = tx;
  cx++;
  tmp = sq(x);
  for (d = 1; d <= tmp; d++) {
    if (x % d == 0) {
      if (cifra(d) == 1) ans++;
      if (d * d != x)
        if (cifra(x / d) == 1) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
