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.*;
import java.util.*;
public class Main{
    public static int check(int n,int x){
        String main_str = String.valueOf(n);
        String sub_str = String.valueOf(x);
        if(sub_str.length()>1){
        for(int i=0;i<sub_str.length();i++){
            if(main_str.indexOf(sub_str.charAt(i))!=-1)
            return 1;
        }
        return 0;
        }
        else{
            if(main_str.contains(sub_str))
            return 1;
            else
            return 0;
        }
    }
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int res=0;
        for(int j=1;j<=Math.sqrt(n);j++)
        {
            if(n%j==0)
            {
                int ct=check(n,j);
                res=res+ct;
                if(j!=(n/j)){
                    int ct1=check(n,n/j);
                    res=res+ct1;
                }
            }
        }
        System.out.println(res);
    }
}