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.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class B {
	Scanner sc = new Scanner(System.in);
	boolean f(int m, int n)
	{
		int [] md = new int [10];
		int [] nd = new int [10];
		do {
			int d = m % 10; md[d]++;
			m /= 10;
		} while(m != 0);
		do {
			int d = n % 10; nd[d]++;
			if(md[d] > 0) return true;
			n /= 10;
		} while(n != 0);
		return false;
	}
	void doIt()
	{
		int x = sc.nextInt();
		int ans = 0;
		int i;
		for(i = 1; i * i <= x; i++) {
			int k = x / i;
			if(i * k == x ) {
				//System.out.print(i + " " + k);
				if(f(i, x)) ans++; 
				if(i != k && f(k, x)) ans++; 
				//System.out.println();
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new B().doIt();
	}
	void debug(Object...os) {
		System.err.println(deepToString(os));
	}
}
