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.Scanner;

/**
 *
 * @author DELL
 */
public class CodeForce221BLittleElephantAndNumbers {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s =new Scanner(System.in);
        int n = s.nextInt();
        String N;
        N=String.valueOf(n);
        int i=1,count=0,temp,max;
        while(i<=Math.sqrt(n)){
            if(n%i==0){
                temp=n/i;
                char[] x = String.valueOf(i).toCharArray();
                char[] y = String.valueOf(temp).toCharArray();
                for (int j = 0; j < x.length; j++) {
                    if(N.indexOf(x[j])!=-1){
                        count++;
                        break;
                    }
                }
                if(temp!=i){
                    for (int j = 0; j < y.length; j++) {
                        if(N.indexOf(y[j])!=-1){
                            count++;
                            break;
                        }
                    }
                }
            }
            i++;
         }
        System.out.println(count);
    }
}