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.lang.*;
import java.math.*;
public class A {
    public static Set<Integer> factors(int n) {
        Set<Integer> factors = new HashSet<Integer>();
        factors.add(1);
        factors.add(n);
        for (int i = 2; i <= Math.sqrt(n)+1; i++) {
            if (n % i == 0) {
                factors.add(i);
                factors.add(n/i);
            }
        }
        return factors;
    }
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); 
        int n = Integer.parseInt(bf.readLine());
        int counter = 0;
        for(int m : factors(n)) {
            String s = ""+m;
            String t = n+"";
            boolean test = false;
            for(int i=0; i<s.length(); i++)
                for(int j=0; j<t.length(); j++)
                    if(s.charAt(i) == t.charAt(j))
                        test = true;
            if(test) counter++;         
        }
        System.out.println(counter);
        
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();
        
        // out.close(); System.exit(0);
    }
}
