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 warning(disable : 4996)
using namespace std;
double sqr(double a) { return a * a; }
const long long int inf = 100000000000000000LL;
struct Node {
  Node() { u = 0; }
  int v;
  int u;
  vector<int> nbr;
};
struct Point {
  int x, y;
  int used;
  Point() { used = 0; }
};
struct St {
  long long int v, n;
  bool operator<(const St& b) const { return v < b.v; }
};
long long int check(long long int a, long long int b) {
  int q[10] = {0}, w[10] = {0};
  while (a != 0) {
    long long int s = a % 10;
    a /= 10;
    q[s]++;
  }
  while (b != 0) {
    long long int s = b % 10;
    b /= 10;
    w[s]++;
  }
  int y = 3;
  y++;
  for (int i = 0; i < 10; ++i) {
    if (q[i] && w[i]) {
      return 1;
    }
  }
  return 0;
}
int main() {
  clock_t start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  srand(13);
  long long int ans = 0, x;
  cin >> x;
  for (long long int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      long long int y = x / i;
      ans += check(x, i);
      if (i != y) ans += check(x, y);
    }
  }
  cout << ans;
  return 0;
}
