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;
inline void in(int &x) { scanf("%d", &x); }
inline void in(int &x, int &y) { scanf("%d %d", &x, &y); }
inline void out(int x) { printf("%d ", x); }
inline void outln(int x) { printf("%d\n", x); }
inline int _abs(int x) { return x > 0 ? x : -x; }
int x, d;
vector<bool> getvect(int n) {
  vector<bool> res(10);
  char buf[15];
  sprintf(buf, "%d", n);
  for (int i = 0; buf[i]; ++i) res[buf[i] - '0'] = true;
  return res;
}
int check(int a, int b) {
  vector<bool> A = getvect(a), B = getvect(b);
  for (int i = 0; i < 10; ++i) {
    if (A[i] && B[i]) {
      return 1;
    }
  }
  return 0;
}
int main() {
  in(x);
  int cnt = 0;
  for (int d = 1; d * d <= x; ++d) {
    if (x % d == 0) {
      if (d * d == x)
        cnt += check(x, d);
      else {
        cnt += check(x, d);
        cnt += check(x, x / d);
      }
    }
  }
  out(cnt);
  return 0;
}
