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 java.io.*;
import java.math.*;

public class Main {
    public static Scanner scan = new Scanner(System.in);
    public static boolean bg = false;

    public static void main(String[] args) throws Exception {
        int n1 = Integer.parseInt(scan.next());
        HashSet<Integer> l1 = new HashSet();
        for (int i=1;i<(int)Math.sqrt(n1)+1;i++){
            if (n1%i==0){
                l1.add(i);
                l1.add(n1/i);
            }
        }
        
        if (bg) System.out.println(l1);
        
        
        HashSet<Character> set1 = new HashSet();
        for (char e: (n1+"").toString().toCharArray() ){
            set1.add(e);
        }
        
        int fin = 0;
        for (int e: l1){
            char[] temp = (e+"").toCharArray();
            for (char f: temp){
                if (set1.contains(f) ){
                    fin++;
                    break;
                }
            }
        }
        
        
        System.out.println(fin);
    }
}
