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 c[1001];
void divis_list(vector<unsigned int> &divis_list, unsigned int num) {
  unsigned int rt = int(sqrt((double)num));
  divis_list.push_back(1);
  for (unsigned int i = 2; i <= rt; i++) {
    if (num % i == 0) {
      divis_list.push_back(i);
      if (num / i != i) {
        divis_list.push_back(num / i);
      }
    }
  }
  if (num != 1) {
    divis_list.push_back(num);
  }
  return;
}
int nd[10];
int main(void) {
  char buf[1024];
  int n;
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &n);
  vector<unsigned int> d;
  divis_list(d, n);
  while (n) {
    nd[n % 10] = 1;
    n /= 10;
  }
  int count = 0;
  for (__typeof__((d).begin()) it = (d).begin(); it != (d).end(); ++it) {
    int n = *it;
    bool flag = 0;
    while (n) {
      if (nd[n % 10]) {
        flag = 1;
        break;
      }
      n /= 10;
    }
    if (flag) {
      ;
      count++;
    } else {
      ;
    }
  }
  printf("%d\n", count);
  return 0;
}
