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 mego() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool common_digit(int x, int y) {
  int digit = 0;
  string s1 = to_string(x), s2 = to_string(y);
  for (int i = 0; i < s1.size(); i++) {
    for (int j = 0; j < s2.size(); j++)
      if (s1[i] == s2[j]) {
        digit = 1;
        break;
      }
  }
  return digit == 1;
}
int main() {
  mego();
  int n, c = 1;
  cin >> n;
  if (n == 1) return cout << 1, 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      c += common_digit(n, i);
      if (n / i != i) c += common_digit(n, n / i);
    }
  }
  for (int i = 1; i <= min(1000000000, n); i *= 10)
    if ((n / i) % 10 == 1) {
      c++;
      break;
    }
  cout << c;
  return 0;
}
