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;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long x;
vector<long long> v;
int cnt[10];
int cnt1[10];
void dig() {
  long long b = x;
  while (b > 0) {
    cnt[(b % 10)]++;
    b /= 10;
  }
}
void dig1(int i) {
  long long b = v[i];
  while (b > 0) {
    cnt1[(b % 10)]++;
    b /= 10;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> x;
  dig();
  int ans = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      v.push_back(i);
      if ((x / i) != i) v.push_back(x / i);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    memset(cnt1, 0, sizeof cnt1);
    dig1(i);
    for (int j = 0; j < 10; j++) {
      if (cnt[j] && cnt1[j]) {
        ans++;
        break;
      }
    }
  }
  cout << ans;
}
