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
import java.util.*;
import static java.lang.Math.*;
public class ProblemB {
        void run() {
                Scanner sc = new Scanner(System.in);
                int counter = 0;
                int n = sc.nextInt();
                for (int i=1; i<=Math.sqrt(n); i++) {
                        if (n % i == 0) {
                                int divisorOne = i;
                                int divisorTwo = n / i;
                                if (haveSameDigit(i, n)) {
                                        counter++;
                                }
                                if (divisorOne != divisorTwo) {
                                        if (haveSameDigit(divisorTwo, n)) {
                                                counter++;
                                        }
                                }
                        }
                }
                p("%d\n", counter);
        }

        boolean haveSameDigit(int n, int i) {
                String a = i + "";
                String b = n + "";
                for (int k=0; k<a.length(); k++) {
                        char q = a.charAt(k);
                        if (b.indexOf(q) != -1) {
                                return true;
                        }
                }
                return false;
        }

        boolean debug = false;
        void p(String f, Object...params) {
                System.out.printf(f, params);
        }
        void d(Object...params) {
                if (debug) {
                        p("DEBUG: %s\n", Arrays.deepToString(params));
                }
        }
        public ProblemB(String[] args) {
                if (args.length > 0 && args[0].equals("debug")) {
                        debug = true;
                }
        }
        public static void main(String[] args) {
                new ProblemB(args).run();
        }
}
