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;
const int N = 1000005;
int a[N];
char s1[N];
char s2[N];
int n;
bool Judge(char s1[], char s2[], int len) {
  int len1 = strlen(s2);
  for (int j = 0; j < len; j++) {
    for (int k = 0; k < len1; k++)
      if (s1[j] == s2[k]) return 1;
  }
  return 0;
}
int main() {
  cin >> n;
  int t = (int)sqrt(1.0 * n);
  memset(s1, 0, sizeof(s1));
  memset(s2, 0, sizeof(s2));
  sprintf(s1, "%d", n);
  int cnt = 0;
  for (int i = 1; i <= t; i++) {
    if (n % i == 0) {
      if (i * i == n)
        a[cnt++] = i;
      else {
        a[cnt++] = i;
        a[cnt++] = n / i;
      }
    }
  }
  int c = 0;
  int len = strlen(s1);
  for (int i = 0; i < cnt; i++) {
    memset(s2, 0, sizeof(s2));
    sprintf(s2, "%d", a[i]);
    if (Judge(s1, s2, len)) c++;
  }
  cout << c << endl;
  return 0;
}
