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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader; 
import java.io.FileWriter;
//import java.lang.StringBuilder;
import java.util.StringTokenizer;
//import java.lang.Comparable;
//import java.util.Arrays;
import java.util.HashMap;
//import java.util.ArrayList;
//import java.util.LinkedList;

public class LittleElephantAndNumbers {
    
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);
    //static StringBuilder sb = new StringBuilder();
    static String str;
    static HashMap<Character, Boolean> map = new HashMap<>();
    
    public static void main(String[] args) throws IOException {
        //StringTokenizer st = new StringTokenizer(in.readLine());
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        str = in.readLine();
        char[] c = str.toCharArray();
        for(int i = 0; i < c.length; i++)
            map.put(c[i], true);
        int x = Integer.parseInt(str);
        int t = 0;
        double r = Math.sqrt(x);
        for(int i = 1; i <= r; i++) {
            if(x % i == 0) {
                int a = x / i;
                if(a != i)
                    if(verifier(a+""))
                        t++;
                if(verifier(i+""))
                    t++;
            }
        }
        out.print(t);
        out.close();
    }
    
    public static boolean verifier(String n) {
        char[] c = n.toCharArray();
        for(int i = 0; i < c.length; i++)
            if(map.containsKey(c[i]))
                return true;
        return false;
    }
}