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;
bool isprime[100005];
int prime[100005], nprime;
void getprime() {
  nprime = 0;
  memset(isprime, 1, sizeof(isprime));
  long long i, j;
  for (i = 2; i < 100005; i++)
    if (isprime[i]) {
      prime[nprime++] = i;
      for (j = i * i; j < 100005; j += i) isprime[j] = 0;
    }
}
char c[10];
int len;
bool judge(int x) {
  int m = 1000000000;
  int q = x;
  char s[50];
  sprintf(s, "%d", x);
  int len2 = strlen(s);
  for (int i = 0; i < len2; i++)
    for (int j = 0; j < len; j++)
      if (s[i] == c[j]) return 1;
  return 0;
}
int main() {
  while (cin >> c) {
    len = strlen(c);
    long long a = 0;
    for (int i = 0; i < len; i++) a = a * 10 + c[i] - '0';
    int num = 0, i;
    for (i = 1; i * i < a; i++)
      if (a % i == 0) {
        if (judge(i)) {
          num++;
        }
        if (judge(a / i)) {
          num++;
        }
      }
    if (i * i == a && judge(i)) num++;
    cout << num << endl;
  }
  return 0;
}
