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.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        
        int d[] = NumUtils.getDivisors(n);
        
        int s = 0;
        String str = ""+n;
        for(int x : d){
            for(char c : (""+x).toCharArray()) 
                if(str.indexOf(c)>=0){ ++s; break; }
        }
        
        out.writeln(s);
    }
}

class InputReader{
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    
    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
    
    public String next(){
        while(tokenizer==null || !tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    
    public int nextInt(){
        return Integer.parseInt(next());
    }

    }

class OutputWriter{
    private PrintWriter out;
    
    public OutputWriter(Writer out){
        this.out = new PrintWriter(out);
    }

    public OutputWriter(OutputStream out){
        this.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
    }
    
    public void close(){
        out.close();
    }

    public void writeln(Object ... o){
        for(Object x : o) out.print(x);
        out.println();
    }
}

class NumUtils {
    
    public static int[] getDivisors(int n){
        int sqrt = (int)sqrt(n);
        int isFullSquare = (sqrt*sqrt==n ? 1 : 0);
        int[] d = new int[sqrt];
        int m=0, i;
        for(i=1; i<=sqrt; ++i) if(n%i==0) d[m++]=i;
        int res[] = new int[m+m-isFullSquare];
        for(i=0; i<m; ++i) res[i]=d[i];
        for(i=m-1-isFullSquare; i>=0; --i) res[m+m-i-1-isFullSquare]=n/d[i];
        return res;
    }

    public static long sqrt(long n){
        if(n==0) return 0;
        long nx, x = 2;
        boolean d = false;
        for(;;){
            nx=(x + n/x)>>1;
            if(x==nx || nx>x && d) return x;
            d=(nx<x);
            x=nx;
        }
    }
}

