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
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
// import java.math.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static HashSet<Character> hs=new HashSet<>();
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            PrintWriter ot=new PrintWriter(System.out);
            int t=1;//Integer.parseInt(br.readLine().trim());
            // int total=0;
            while(t-->0)
            {
                String ss[]=br.readLine().trim().split(" ");
                int n=Integer.parseInt(ss[0]);
                String s=Integer.toString(n);
                int len=s.length();
                for(int i=0;i<len;i++)
                hs.add(s.charAt(i));
                
                ot.println(find(n));
            }
            ot.close();
            br.close();
            
        } catch(Exception e){
            e.printStackTrace();
            return;
        }
    }
    public static int find(int n){
        int count=0;
        for(int i=1;i<=Math.sqrt(n);i++)
        {
            if(n%i==0)
            {
                if(n/i==i)
                {
                    if(check(i))
                    count++;
                }
                else
                {
                    if(check(i))
                    count++;
                    if(check(n/i))
                    count++;
                }
            }
        }
        return count;
    }    
    public static boolean check(int n){
        
        String s=Integer.toString(n);
        int len=s.length();

        for(int i=0;i<len;i++)
        if(hs.contains(s.charAt(i)))
        return true;
        return false;
    }
}
    