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>
#pragma comment(linker, '/STACK:200000')
const int INF = 1e9 + 7;
const double EPS = 1e-6;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 1e5 + 1000;
using namespace std;
int x, cnt[10], tmp[10];
set<int> st;
int main() {
  cin.tie(0);
  ios_base ::sync_with_stdio(0);
  cin >> x;
  for (int i = 2; i * 1ll * i <= x; i++) {
    if (x % i == 0) st.insert(i), st.insert(x / i);
  }
  int cur = x;
  while (cur) {
    cnt[cur % 10]++;
    cur /= 10;
  }
  st.insert(1);
  st.insert(x);
  int ans = 0;
  for (auto it : st) {
    for (int i = 0; i < 10; i++) tmp[i] = 0;
    cur = it;
    while (cur) {
      tmp[cur % 10]++;
      cur /= 10;
    }
    for (int i = 0; i < 10; i++)
      if (tmp[i] && cnt[i]) {
        ans++;
        break;
      }
  }
  cout << ans;
  return 0;
}
