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
//Date: Oct 14, 2013 
//Time: 12:12:39 PM

import java.util.*;
import java.io.*;

public class B221 implements Runnable {
	boolean[] digit;
	public void solve() throws IOException {
		int N = nextInt();
		digit = new boolean[10];
		int n = N;
		while(n > 0) {
			digit[n % 10] = true;
			n = n / 10;
		}
		
		int ans = 0;
		for(int i = 1; i * i <= N; i++){
			if(N % i == 0){
				if(has(i)) ans++;
				if(N / i != i && has(N / i)) ans++;
			}
		}
		System.out.println(ans);
	}
	
	public boolean has(int n){
		while(n > 0) {
			if(digit[n % 10]) return true;
			n = n / 10;
		}
		
		return false;
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	//-----------------------------------------------------------
	public static void main(String[] args) {
		new B221().run();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tok = null;
			solve();
			in.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

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

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

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

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	BufferedReader in;
	StringTokenizer tok;
}
/**
public class B221 {

}
 
*/