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.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.*;
public class hacker
{
    /*FAtt gyi bbhai*/
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        new hacker().run();
    }
    void run()
    {
       FastReader sc = new FastReader();
       int n = sc.nextInt();
       int c=0;
        for(int i=1;i<=Math.sqrt(n);i++)
       {
            if(n%i==0 && common(n,i))
            {
                c++;
            }
            if(n/i!=i && n%i==0&& common(n,n/i))
            {
                c++;
            }
       }
       System.out.println(c);


    }

    static boolean common(int x,int y)
    {
        HashSet<Integer> hash = new HashSet<>();
        while(x>0)
        {
            hash.add(x%10);
            x = x/10;
        }
        while(y>0)
        {
            if(hash.contains(y%10))
            {

                return true;
            }
            y = y/10;
        }
        return false;
    }

   

    
   


    
}

   
