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;
map<int, bool> mp;
bool func(int x) {
  int a;
  while (x) {
    a = x % 10;
    if (mp[a]) {
      return true;
    }
    x /= 10;
  }
  return false;
}
int main() {
  int n, i, a, j, t, ans = 0;
  cin >> n;
  set<int> st;
  t = sqrt(n);
  for (i = 1; i <= t; i++) {
    if (n % i == 0) {
      st.insert(i);
      st.insert(n / i);
    }
  }
  while (n) {
    a = n % 10;
    mp[a] = true;
    n /= 10;
  }
  set<int>::iterator it;
  for (it = st.begin(); it != st.end(); it++) {
    int p = *it;
    if (func(p)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
