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.*;
public class E
{
	
	private static Scanner scan = new Scanner(System.in);
	static boolean[] dig= new boolean[10];
	public static boolean ok(int x) {
		int num=x;
		while(num>0) {
			int d=num%10;
			if(dig[d]) {
				return true;
			}
			num/=10;
		}
		return false;
	}
	public static void main(String[] args)
    {
        int n=scan.nextInt();
        int num=n;
        while(num>0){
            int d = num%10;
            dig[d] = true;
            num/=10;
        }
        ArrayList<Integer> a= new ArrayList<Integer>();
        for(int i=1;i*i<=n;i++) {
        	if(n%i==0) {
        		int a1=i,b=n/i;
        		if(a1!=b) {
        			a.add(a1);
        			a.add(b);
        		}else {
        			a.add(a1);
        		}
        	}
        }
        int cnt=0;
        for (Integer integer : a) {
			if(ok(integer)) {
				cnt++;
			}
		}
        
        System.out.println(cnt);
    }
}