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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {
	
	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	static int N;
	static boolean b[][],c[],h;
public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");
	 
		 
	  while(sc.hasNext()){
		   //long sum=0;
		//  int n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=0;
	   
		  int n=sc.nextInt(),m=n;
		  ArrayList<Integer> lis = new ArrayList<Integer>();
	  
		  boolean b[]=new boolean[10];
		 for(; 0<m ;){ b[m%10]=true; m/=10; } 
	//	 db(b); 
		 
		 for(int i=1;i<=sqrt(n);i++){

			 if(n%i==0){ lis.add(i); if( i!=n/i )lis.add(n/i); }
			 
		 }
		 
		 int c=0;
		 for(int i=0;i<lis.size();i++){
			 int k=lis.get(i);
		// db(k);
			 for(; 0<k ;){   if(b[k%10]  ){c++; break;}  k/=10; }  
			 
		 }
		 
		 System.out.println(c);
	 
	  
}
	  }
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);
	 	
	 	//pw.flush();
	 	//pw.close();   
	
   

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));
 
	}

}

class P {
    int v,vv,c;
	P(int v,int vv,int c){
		this.v=v;
	    this.vv=vv;
	    this.c=c;
	} 	
 

}