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.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class _408B {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
        String n=(r.readLine());
                
        boolean arr[] = new boolean[10];
    Arrays.fill(arr, false);    

        for(int i=0;i<n.length();i++)
        {
            arr[n.charAt(i)-'0']=true;
            
        }
        
        int x=Integer.parseInt(n);
        
        int count=0;
        for(int i=1;i<Math.sqrt(x);i++)
        {
            if(x%i==0)
            {
                
                String temp=String.valueOf(x/i);
                for(int j=0;j<temp.length();j++)
                {
                    if(arr[temp.charAt(j)-'0'])
                        {count++;
                        
                        break;
                        }
                    
                }
                temp=String.valueOf(i);
                for(int j=0;j<temp.length();j++)
                {
                    if(arr[temp.charAt(j)-'0'])
                        {count++;
                        
                        break;
                        }
                    
                }
                
            }
            
        }
        if((int)Math.sqrt(x)*(int)Math.sqrt(x)==x)
        {
            
            String temp=String.valueOf((int)Math.sqrt(x));
            for(int j=0;j<temp.length();j++)
            {
                if(arr[temp.charAt(j)-'0'])
                    {count++;
                    
                    break;
                    }
                
            }
        }
        System.out.println(count);
            

}}
