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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt(),ans=0;
        String z=Integer.toString(x);
        Vector<Integer>vec=div(x);
        for(int i=0;i<vec.size();i++){
            String u=Integer.toString(vec.get(i));
            boolean t=false;
            for(int c=0;c<u.length();c++){
                if(z.contains(Character.toString(u.charAt(c)))){
                    t=true;
                    break;
                }
            }
            if(t)
                ans++;
        }
        System.out.println(ans);
    }
    static Vector<Integer>div(int a){
        Vector<Integer>dd=new Vector<>();
        for(int i=1;i<=Math.sqrt(a);i++){
            if(a%i==0){
                if(a/i==i)
                    dd.add(i);
                else{
                    dd.add(i);
                    dd.add(a/i);
                }
            }
        }
        return dd;
    }



    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}