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 math

def check(n,p):
	a = [False for i in xrange(0,10)]
	b = [False for i in xrange(0,10)]
	
	while (n>0):
		m = n%10
		
		a[m] = True
		
		n /= 10
		
	while (p>0):
		m = p%10
		
		b[m] = True
		
		p /= 10
		
	for i in range (0,10):
		if (a[i] == True and b[i] == True):
			return True
			
	return False

def main ():
	n = input()
	
	lim = int(math.sqrt(n))
	
	ans = 0
	
	for i in range (1,lim+1):
		p = i
		q = n/i
		
		if (n%p == 0):
			if (check(n,p)==True):
				ans += 1
				
		if (p!=q and n%q==0):
			if (check(n,q)==True):
				ans += 1
				
	print ans
	
while (True):
	try:
		main ()
		
	except EOFError:
		break