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.io.PrintWriter;
import java.util.*;

public class Main
{
    public static boolean check(String  Number,String Divi)
    {
        for (int i = 0; i <=9; i++) {
            String ch = i+"";
            if(Number.contains(ch)&&Divi.contains(ch))
            {
                return true;
            }
        }
        return false;
    }


    public static void main(String[] args) throws IOException
    {
        FastScanner input = new FastScanner();
		long a = input.nextLong();
                TreeSet<Long> set =new  TreeSet<>();
                for (long i = 1; i <=Math.sqrt(a); i++) {
            if(a%i==0)
            {
                set.add(i);
                if(a/i!=i)
                {
                    set.add(a/i);
                }
            }
        }
                int count=0;
                for (Long long1 : set) {
            boolean ok = check(long1+"",a+"");
            if(ok)count++;
        }
                System.out.println(count);
            
        
        
    }
    static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			
			return Long.parseLong(next());
		}
                double nextDouble()
                {
                    return Double.parseDouble(next());
                }
	}

}
