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 main() {
  int x, i, ans = 0, k = 0, ig = 0;
  cin >> x;
  int a[10], b[100000];
  for (i = 0; i < 10; i++) a[i] = 0;
  int y = x;
  while (y > 0) {
    a[y % 10]++;
    y = y / 10;
  }
  for (i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      int j = i, flag = 0;
      b[k] = i;
      k++;
      while (j > 0 && flag == 0) {
        if (a[j % 10] > 0) flag = 1;
        j = j / 10;
      }
      if (flag > 0) {
        ans++;
        if (i == sqrt(x)) ig = i;
      }
    }
  }
  for (i = 0; i < k; i++) {
    int j = x / b[i], flag = 0;
    if (j == ig) ans--;
    while (j > 0 && flag == 0) {
      if (a[j % 10] > 0) flag = 1;
      j = j / 10;
    }
    if (flag > 0) ans++;
  }
  if (x == 1) ans = 1;
  cout << ans << endl;
  return 0;
}
