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.BufferedInputStream;
import java.io.IOException;
import java.util.Scanner;


public class B221 {
	public static void main(String[] args) throws IOException {
		solve();
	}
	
	public static void solve()throws IOException{
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		int n = scan.nextInt();
		boolean dig[] = new boolean[10];
		int t = n;
		while(t > 0){
			dig[t%10]=true;
			t /= 10;
		}
		
		int count = 0;
		int sqrt = (int)Math.sqrt(n);
		for (int i = 1; i < sqrt; i++) {
			if(n%i == 0){
				if(isMatching(i,dig))
					count++;
				if(isMatching(n/i,dig))
					count++;
			}
		}
		
		if(n%sqrt == 0){
			if(isMatching(sqrt,dig))
				count++;
			if(sqrt != (n/sqrt) && isMatching(n/sqrt,dig))
				count++;
		}
		
		System.out.println(count);
	}
	
	private static boolean isMatching(int t, boolean digits[]){
		while(t > 0){
			if(digits[t%10]){
				return true;
			}
			t /= 10;
		}
		return false;
	}
}
