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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;

public class ProblemDiv2B {
    
    static Random r = new Random(1000000009);
    
    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int cnt = 0;
        int n = Integer.valueOf(s.readLine());
        String nstr = String.valueOf(n);
        for (int d = 1 ; d * d <= n ; d++) {
            if (n % d == 0) {
                if (check(d, nstr)) {
                    cnt++;
                }
                if (d * d != n && check(n / d, nstr)) {
                    cnt++;
                }
            }
        }
        out.println(cnt);
        out.flush();
    }

    private static boolean check(int x, String nstr) {
        String ival = String.valueOf(x);
        for (int i = 0 ; i < ival.length() ; i++) {
            char c = ival.charAt(i);
            if (nstr.contains("" + c)) {
                return true;
            }
        }
        return false;
    }

    public static void debug(Object... os){
        System.err.println(Arrays.deepToString(os));
    }

}
