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 double eps = 1e-6;
const double PI = 3.14159265358979323846264338f;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const long long mod = 100000007;
const int MAXN = 50005;
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
inline int read() {
  int c = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    c = c * 10 + ch - '0';
    ch = getchar();
  }
  return c * f;
}
bool a[10];
int main() {
  memset(a, false, sizeof(a));
  int n;
  cin >> n;
  memset(a, false, sizeof(a));
  int sum = 0;
  int temp = n;
  while (temp) {
    a[temp % 10] = true;
    temp /= 10;
  }
  int r = sqrt(n);
  for (int i = 1; i <= r; i++) {
    if (n % i == 0) {
      int t = i;
      bool flog = false;
      while (t) {
        if (a[t % 10]) {
          flog = true;
          break;
        }
        t /= 10;
      }
      if (flog) sum++;
      if (i * i != n) {
        t = n / i;
        flog = false;
        while (t) {
          if (a[t % 10]) {
            flog = true;
            break;
          }
          t /= 10;
        }
        if (flog) sum++;
      }
    }
  }
  cout << sum << "\n";
  return 0;
}
