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

public class CF{public static void main(String[]args)throws IOException{S s=new S();s.s();s.output();}}class S{
    void s() throws IOException {
        int x = NI();
        boolean[] digs = new boolean[10];
        for (int tx = x; tx > 0; tx /= 10)
            digs[tx % 10] = true;
        int cnt = 0;
        for (int i = 1; i <= (int)Math.sqrt(x); i++)
            if (x % i == 0)
                for (int k = 0; k < 2 && (k < 1 || i != x / i); k++)
                    for (int tx = k == 0 ? i : x / i; tx > 0; tx /= 10)
                        if (digs[tx % 10]) {
                            cnt++;
                            break;
                        }
        sout(cnt);
    }

    BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));StringTokenizer st=new StringTokenizer("");long LINF=Long.MAX_VALUE;
    StringBuilder output=new StringBuilder();final int INF=Integer.MAX_VALUE;void sout(Object x){output.append(x.toString()).append('\n');}
    void inLong(long[]a,int n){for(int i=0;i<n;i++)a[i]=NL();}int min(int i1,int i2){return i1<i2?i1:i2;}double ND(){return Double.parseDouble(NS());}
    long min(long i1,long i2){return i1<i2?i1:i2;}int max(int i1,int i2){return i1>i2?i1:i2;}long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS(){while(!st.hasMoreTokens())try{st=new StringTokenizer(stdin.readLine());}catch(IOException ignored){}return st.nextToken();}
    int NI(){return Integer.parseInt(NS());}long NL(){return Long.parseLong(NS());}String NLn()throws IOException{return stdin.readLine();}
    int abs(int x){return x<0?-x:x;}long abs(long x){return x<0?-x:x;}void sout(){output.append('\n');}void out(Object x){output.append(x.toString());}
    int mod(int x,int mod){return(x+mod)%mod;}void output(){System.out.print(output);}void inInt(int[]a,int n){for(int i=0;i<n;i++)a[i]=NI();}
}