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.*;
    public class Main {
        public static long mod= (long) (1e9 +7);
        public static void main(String args[]){
            InputReader s= new InputReader(System.in);
            OutputStream outputStream= System.out;
            PrintWriter out= new PrintWriter(outputStream);
            int n= s.nextInt();
            HashSet<Integer> ans= new HashSet<>();
            for(int i=1;i<=Math.sqrt(n);i++){
                if(n%i==0){
                    ans.add(i);
                    ans.add(n/i);
                }
            }
            String str= Integer.toString(n);
            int size= str.length();
            ArrayList<Integer> arr= new ArrayList<Integer>();
            for(int i=0;i<size;i++){
                arr.add((int)str.charAt(i)-48);
            }
            int count=0;
            Iterator iterator= ans.iterator();
            while(iterator.hasNext()){
                String str1= iterator.next().toString();
                //out.println(str1);
                int size1= str1.length();
                for(int j=0;j<size1;j++){
                    //out.println(str1+" "+str1.charAt(j));
                    if(arr.contains((int)str1.charAt(j)-48)){
                        count++;
                        break;
                    }
                }
            }
            out.println(count);
            //out.println(ans);
            /*String str1 = null;
            HashSet<Integer> ans1= new HashSet<>();
            for(int i=1;i<size;i++){
                for(int j=0;j<size;j++){
                    if(j+i<= size)
                         str1= str.substring(j, j+i);
                    int m= Integer.parseInt(str1);
                    if(m==1) ans1.add(m);
                    else if(m!=0){
                        if(n%m==0)
                            ans.add(m);
                    }
                }
            }
            //out.println(ans);
            //out.println(ans.size()+1);*/
            
            out.close();
        }
        static class InputReader {
    
            public BufferedReader reader;
            public StringTokenizer tokenizer;
     
            public InputReader(InputStream inputstream) {
              reader = new BufferedReader(new InputStreamReader(inputstream));
              tokenizer = null;
            }
            
            public String nextLine(){
                String fullLine=null;
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    try {
                      fullLine=reader.readLine();
                    } catch (IOException e) {
                      throw new RuntimeException(e);
                    }
                    return fullLine;
                  }
                  return fullLine;
            }
            public String next() {
              while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                  tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                  throw new RuntimeException(e);
                }
              }
              return tokenizer.nextToken();
            }
            public long nextLong() {
                  return Long.parseLong(next());
                }
            public int nextInt() {
              return Integer.parseInt(next());
            }
          }
        static class Pair implements Comparable<Pair>
        {
            long f,s;
            Pair(long ii, long cc)
            {
                f=ii;
                s=cc;
            }
            
            public int compareTo(Pair o) 
            {
                return Long.compare(this.f, o.f);
            }
            
        }
        public static int gcd(int number1, int number2) {  
            if(number2 == 0){
                return number1;
            } 
            return gcd(number2, number1%number2); 
        }
        public static int combinations(int n,int r){
            if(n==r) return 1;
            if(r==1) return n;
            if(r==0) return 1;
            return combinations(n-1,r)+ combinations(n-1,r-1);
        }
        public static long binomialCoeff(int n, int k)
        {
            long C[][]= new long[n+1][k+1];
            int i, j;
         
            // Caculate value of Binomial Coefficient in bottom up manner
            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= Math.min(i, k); j++)
                {
                    // Base Cases
                    if (j == 0 || j == i)
                        C[i][j] = 1;
         
                    // Calculate value using previosly stored values
                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }
         
            return C[n][k];
        }
        public static int expo(int a, int b){
            if (b==1)
                return a;
            if (b==2)
                return a*a;
    
            if (b%2==0){
                    return expo(expo(a,b/2),2);
            }
            else{
                return a*expo(expo(a,(b-1)/2),2);
            }
        }
        
        public static void sieve(int N){
            int arr[]= new int[N+1];
            for(int i=2;i<Math.sqrt(N);i++){
                if(arr[i]==0){
                    for(int j= i*i;j<= N;j= j+i){
                        arr[j]=1;
                    }
                }
            }
            // All the i for which arr[i]==0 are prime numbers.
        }
    }
    
