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
/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Divisor {
	private static boolean common(int a,int b)
	{
		int i;
		String s1=Integer.toString(a);
		String s2=Integer.toString(b);
		boolean[] a1=new boolean[10];
		boolean[] a2=new boolean[10];
		for(i=0;i<s1.length();i++)
		{
			char character = s1.charAt(i); 
			int as = (int) character;
			a1[as-48]=true;
		}
		for(i=0;i<s2.length();i++)
		{
			char character = s2.charAt(i); 
			int as = (int) character;
			a2[as-48]=true;
		}
		for(i=0;i<=9;i++)
		{
			if(a1[i]==true && a2[i]==true)
				return true;
		}
		return false;
	}
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		int n=in.nextInt(),cnt=0;
		for(int i=1 ; i<=Math.sqrt(n) ; i++)
		{
			if(n%i==0)
			{				
				if(i==n/i)
				{
					if(common(n, i)==true)
						cnt++;
				}
				else
				{
					if(common(n, i)==true)
						cnt++;
					if(common(n, n/i)==true)
						cnt++;
				}
			}
		}
		System.out.println(cnt);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}
