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;

public class Task221B {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		
		int[] nd = new int[10];
		int nTemp = n;
		while (nTemp != 0) {
			nd[nTemp % 10]++;
			nTemp /= 10;
		}
		
		int d = 0;		
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				int[] id = new int[10];
				int iTemp = i;
				while (iTemp != 0) {
					id[iTemp % 10]++;
					iTemp /= 10;
				}
				for (int j = 0; j < 10; j++) {
					if ((nd[j] > 0) && (id[j] > 0)) {
						d++;
						break;
					}
				}
				if (i * i == n) { break; }
				id = new int[10];
				int jTemp = n / i;
				while (jTemp != 0) {
					id[jTemp % 10]++;
					jTemp /= 10;
				}
				for (int j = 0; j < 10; j++) {
					if ((nd[j] > 0) && (id[j] > 0)) {
						d++;
						break;
					}
				}
			}
		}
		
		System.out.println(d);
	}
}