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;
void view_arr(int a[], int n) {
  for (int i = 0; i <= n; i++) {
    if (!i)
      printf("%d", a[i]);
    else
      printf(" %d", a[i]);
  }
  puts("");
}
int get_digit(int a, int str[]) {
  int t = a, cnt = 0;
  while (t) {
    int r = t % 10;
    t /= 10;
    str[cnt++] = r;
  }
  return cnt - 1;
}
bool judge(int a, int n) {
  int t1[25], t2[25], len1, len2;
  len1 = get_digit(a, t1);
  len2 = get_digit(n, t2);
  for (int i = 0; i <= len2; i++) {
    for (int j = 0; j <= len1; j++) {
      if (t2[i] == t1[j]) return true;
    }
  }
  return false;
}
int deal(int n) {
  int e = sqrt((double)n), cnt = 0;
  for (int i = 1; i <= e; i++) {
    int a = i, b;
    if (n % a == 0) {
      b = n / a;
      if (a != b) {
        if (judge(a, n)) cnt++;
        if (judge(b, n)) cnt++;
      } else {
        if (judge(a, n)) cnt++;
      }
    }
  }
  return cnt;
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int sol = deal(n);
    printf("%d\n", sol);
  }
  return 0;
}
