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.text.DecimalFormat;

import java.util.Scanner;
import java.util.StringTokenizer;
public class B {

	

	// -- DEBUG switch --
	static final boolean DEBUG = false;

	// -- -- 

	static int[] digits = new int[10];
	
	static void countDigits(int x){
		while (x > 0){
			int last = x % 10;
			dbg("%d ", last);
			digits[last]++;
			x = x/10;
		}
		dbg("\n");
	}
	
	static boolean checkDigits(int x){
		while (x > 0){
			int last = x % 10;
			dbg("%d ", last);
			if (digits[last] > 0)
				return true;
			x = x/10;
		}
		return false;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(), cnt = 0;
//		boolean[] v = new boolean[1000000001];
		if (x == 1){
			p("1");
			return;
		}
		countDigits(x);
		for (int i=1; i*i<=x; i++){
			if (x % i == 0){
				if (checkDigits(i))
					cnt++;
				int j = x/i;
				if (j != i){
					if (checkDigits(j))
						cnt++;
				}
			}
		}
		p("%d", cnt);
	}
	
	
	
	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st = null;
	
	static void readIntArrays(int n, int[] a) throws IOException {
		for (int i=0; i<n; i++){
			a[i] = i();
		}
	}
	
	static void dbgArr(int[] a, int s, int e){
		if (DEBUG) {
			System.out.println();
			for (int i=s; i<=e; i++)
				System.out.print(a[i] + " ");
			System.out.println();
		}
	}
	
	static void readIntArrays(int n, int m, int[][] a) throws IOException {
		for (int i=0; i<n; i++){
			for (int j=0; j<n; j++)
				a[i][j] = i();
		}
	}
	static void dbgArr(int[][] a, int rs, int re, int cs, int ce){
		if (DEBUG) {
			System.out.println();
			for (int i=rs; i<=re; i++){
				for (int j=cs; j<=ce; j++)
					System.out.print(a[i][j] + " ");
				System.out.println();
			}
			System.out.println();
		}
	}	
	static String s() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	static int i() throws IOException {
		return Integer.parseInt(s());
	}
	
	static int i(String s) {
		return Integer.parseInt(s);
	}
	
	static long l() throws IOException {
		return Long.parseLong(s());
	}
	
	static long l(String s){
		return Long.parseLong(s);
	}
	
	static double d() throws IOException {
		return Double.parseDouble(s());
	}
	static double d(String s)  {
		return Double.parseDouble(s);
	}	
	
	static void p(String args){
		System.out.print(args);
	}
	
	static void p(String format, Object... args) {
		System.out.print(String.format(format, args));
	}
	
	static void dbg(String format, Object... args){
		if (DEBUG)
			System.out.print(String.format(format, args));
	}
	
	static void dbg(String args){
		if (DEBUG)
			System.out.print(args);
	}
	static void dbgln(String format, Object... args){
		if (DEBUG)
			System.out.println(String.format(format, args));
		
	}
	
	static void dbgln(String args){
		if (DEBUG)
			System.out.println(args);
	}
}



