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;
bool f(int x, int i) {
  bool l = false;
  int a[11], b[11], j, k, c, d, m = i, n = 0;
  for (j = 0; x; j++) {
    a[j] = x % 10;
    x /= 10;
  }
  c = j;
  for (j = 0; i; j++) {
    b[j] = i % 10;
    i /= 10;
  }
  d = j;
  for (j = 0; j < c; j++) {
    for (k = 0; k < d; k++)
      if (a[j] == b[k]) {
        l = true;
        n = 1;
        break;
      }
    if (n) break;
  }
  return l;
}
int main() {
  int x, s = 0, i, k;
  scanf("%d", &x);
  k = (int)sqrt(x);
  for (i = 1; i <= k; i++) {
    if (x % i == 0) {
      if (x / i == i) {
        if (f(x, i)) s++;
      } else {
        if (f(x, i)) s++;
        if (f(x, x / i)) s++;
      }
    }
  }
  printf("%d\n", s);
  return 0;
}
