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;
int stoii(string s) {
  int sum = 0;
  for (int i = 0; i < s.length(); ++i) sum = sum * 10 + s[i] - '0';
  return sum;
}
string itos(int n) {
  string s = "";
  while (n) {
    s += n % 10 + '0';
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
bool same(int a, string ss) {
  string s = itos(a);
  int n = s.length(), nn = ss.length();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < nn; ++j) {
      if (s[i] == ss[j]) return 1;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, ans = 0;
  cin >> n;
  string sn = itos(n);
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (same(i, sn)) ++ans;
      if (i != n / i && same(n / i, sn)) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
