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 prime[100005] = {false};
void sieve() {
  prime[0] = true;
  prime[1] = true;
  for (long long i = 2; i < 100005; i++) {
    if (prime[i] == false) {
      for (long long j = i * i; j < 100005; j += i) prime[j] = true;
    }
  }
}
void solve() {
  long long n, j, a, cnt = 0;
  set<long long> w;
  cin >> n;
  long long m = n;
  while (m > 0) {
    w.insert(m % 10);
    m /= 10;
  }
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      j = i;
      while (j > 0) {
        a = j % 10;
        if (w.find(a) != w.end()) {
          cnt++;
          if (i * i == n) cnt--;
          break;
        }
        j /= 10;
      }
      j = n / i;
      while (j > 0) {
        a = j % 10;
        if (w.find(a) != w.end()) {
          cnt++;
          break;
        }
        j /= 10;
      }
    }
  }
  cout << cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
