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:67108864")
using namespace std;
template <class T>
inline T abs(T a) {
  return (a) > 0 ? (a) : -(a);
}
template <class T>
inline T sqr(T a) {
  return (a) * (a);
}
const long double PI = 3.1415926535897932, EPS = 1E-9;
const int INF = 1000 * 1000 * 1000, NMAX = 1005;
bool was(int i, int j) {
  int used[10];
  memset(used, false, sizeof(used));
  while (i >= 10) {
    used[i % 10] = 1;
    i /= 10;
  }
  used[i] = 1;
  while (j >= 10) {
    if (used[j % 10] == 1) {
      return true;
    }
    j /= 10;
  }
  if (used[j] == 1) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  int ans = 0;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      if (was(i, n)) ++ans;
      if (i != n / i && was(n / i, n)) ++ans;
    }
  cout << ans;
  return 0;
}
