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 f(int n, char a[11]);
bool check(int &x, int d);
int main() {
  int x;
  int c = 0;
  cin >> x;
  for (int d = 1; (d * d) <= x; ++d) {
    if (x % d == 0) {
      if (check(x, d)) ++c;
      if (d * d != x && check(x, x / d)) ++c;
    }
  }
  cout << c;
  return 0;
}
bool check(int &x, int d) {
  static bool fl = true;
  static char sx[11];
  char sd[11];
  if (x == d) return true;
  if (fl) {
    f(x, sx);
    fl = false;
  }
  f(d, sd);
  for (int i = 1; i < sx[0]; ++i)
    for (int j = 1; j < sd[0]; ++j)
      if (sx[i] == sd[j]) return true;
  return false;
}
void f(int n, char a[11]) {
  a[0] = 1;
  while (n) {
    a[a[0]++] = n % 10;
    n /= 10;
  }
}
