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.Scanner;


public class B {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long counter = 1;
        for (int i = 2; i*i<=n; i++){
            if (n%i==0) {
                if (solve(n/i,n)) counter++;
                if (n/i!=i)
                    if (solve(i,n)) counter++;
            }
            
        }
        if (n!=1&&solve (n,1)) counter++;
        System.out.println(counter);
    }
    public static boolean solve(long x, long y){
        char[] a = Long.toString(x).toCharArray();
        char[] b = Long.toString(y).toCharArray();
        for (int i =0; i<a.length; i++)
            for (int j =0; j<b.length; j++)
                if (a[i]==b[j]) return true;
        return false;
    }

}
