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.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class CFB {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        CFB t = new CFB();
        t.init();
    }

    boolean[] digits;

    void run() throws Exception {
        long x = Long();

        digits = new boolean[10];
        String y = x + "";
        for (int i = 0; i < y.length(); i++) {
            digits[y.charAt(i) - '0'] = true;
        }
        int divs = 0;
        for (long d = 1; d * d <= x; d++) {
            if (x % d == 0) {
                if (hasDigit(d)) {
                    divs++;
                }
                if (hasDigit(x / d) && (d != x / d)) {
                    divs++;
                }
            }
        }
        PrintLn(divs);
    }

    boolean hasDigit(long a) {
        String y = a + "";
        for (int i = 0; i < y.length(); i++) {
            if (digits[y.charAt(i) - '0']) {
                return true;
            }
        }
        return false;
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    String String() throws Exception {
        return next();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

}
