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

public class TC
{
    static boolean isPrime[];
    static ArrayList<Integer> primes;
    
    static boolean isValid( int a, int b )
    {
        HashSet<Integer> digits = new HashSet();
        
        while( a > 0 )
        {
            int d = a%10;
            digits.add( d );
            a = a/10;
        }
        
        while( b > 0 )
        {
            int d = b%10;
            
            if( digits.contains(d))
                return true;
            
            b = b/10;
        }
        
        return false;
    }
    
    static void solve( int n )
    {
        HashSet<Integer> div = new HashSet();
        int root = (int)Math.sqrt(n) + 2;
        int cnt = 0;
        
        for( int i=1; i<=root; i++ )
        {
            int d1 = i;
            
            if( n%d1 != 0 )
                continue;
            
            int d2 = n/d1;
            
            if( isValid( n, d1 ))
            {   
                if( !div.contains( d1 ))
                {   
                    div.add( d1 );
                    cnt++;
                }
            }
            
            if( isValid( n, d2 ))
            {
                if( !div.contains( d2 ))
                {   
                    div.add( d2 );
                    cnt++;
                }
            }
            
           
        }
        
        System.out.println( cnt );
    }
    
    public static void main( String[] args ) throws IOException
    {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ));
        
        int N = Integer.parseInt( br.readLine());
        solve( N );
        
 
          
         
        
      
    }
}