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.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class CF_A {

	/**
	 * @param args
	 */

	static BufferedReader brscan = new BufferedReader(new InputStreamReader(
			System.in));
	static PrintWriter pw = new PrintWriter(System.out);
	static Scanner scan = new Scanner(System.in);
	static StringTokenizer stoken;
	
	public static boolean hasSameNumber(int input) {
		String inputStr = input+"";
		for (int n=0; n<inputStr.length(); n++) {
			if (inputBool[inputStr.charAt(n)-'0']) {
				return true;
			}
		}
		return false;
	}
	static boolean[] inputBool;
	public static void main(String[] args) throws Exception {
		
		int input = scan.nextInt();
		int inputLen = (input+"").length();
		String inputStr = input+"";
		inputBool = new boolean[10];
		for (int n=0; n<inputLen; n++) {
			inputBool[inputStr.charAt(n) - '0'] = true;
		}
		int limit = (int) Math.sqrt((double) input) + 1;
		int small, big, count = 0;
		for (int n=1; n<limit; n++) {
			if (input % n ==0) {
				small = n;
				big = input/n;
				if (small!=big) {
					count = (hasSameNumber(small))?count+1:count;
					count = (hasSameNumber(big))?count+1:count;
					
				} else {
					count = (hasSameNumber(small))?count+1:count;
				}
				
			}
		}
		
		System.out.println(count);
		
	}
}


