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.*;
import java.util.*;
public class LittleElephantandNumbers {
	public static void main(String[] args) throws Exception {
		BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
		// Scanner k = new Scanner(System.in);

		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		int n=Integer.parseInt(k.readLine());
		if(n==1){
			System.out.println(1);
			return;
		}
		String num=n+"";
		int[] arr=new int[100000];
		arr[0]=1;
		int el=1;
		for (int i = 2; i*i <= n; i++) {
			if(n%i==0) {
				arr[el++]=i;
				arr[el++]=n/i;
			}
		}
		String s="";
		int count=1;
		for (int i = 0; i < arr.length&&arr[i]!=0; i++) {
			if(i!=0&&arr[i]==arr[i-1]) continue;
			s=arr[i]+"";
			for (int j = 0; j < s.length(); j++) {
				if(num.contains(s.charAt(j)+"")) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
}
