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;
void yala_bena() {
  cin.tie(0);
  std::ios::sync_with_stdio(0);
}
const int m_r = 199999;
double pii = 3.1415926536;
string s(int x) {
  stringstream a;
  string b;
  a << x;
  a >> b;
  return b;
}
vector<string> v;
void divi(int n) {
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i == n / i) {
        v.push_back(s(i));
      } else {
        v.push_back(s(i));
        v.push_back(s(n / i));
      }
    }
  }
}
bool comp(string a, string b) {
  if (a.size() > b.size()) swap(a, b);
  for (int i = 0; i < a.size(); i++) {
    if (b.find(a[i]) != -1) return 1;
  }
  return 0;
}
int main() {
  yala_bena();
  int n, cn = 0;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  divi(n);
  for (int j = 0; j < v.size(); j++) {
    if (comp(s(n), v[j])) cn++;
  }
  cout << cn << endl;
}
