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 a[10];
int t = 0;
int n = 0;
int x;
void check(int m) {
  if (x % m == 0) {
    while (m > 0) {
      int s = m % 10;
      if (a[s] > 0) {
        n++;
        break;
      }
      m /= 10;
    }
  }
}
int main() {
  cin >> x;
  int x0 = x;
  while (x0 > 0) {
    int s = x0 % 10;
    a[s]++;
    x0 /= 10;
  }
  int max = sqrt(x);
  for (int i = 1; i <= max; i++) {
    if (x % i == 0) {
      if (i * i == x) {
        check(i);
      } else {
        check(i);
        check(x / i);
      }
    }
  }
  cout << n << endl;
  return 0;
}
