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
def divisor(s):
    l = []
    for i in range(1,int(s**.5)+1):
        if s % i == 0:
            l.append(i)
            l.append(s//i)
    return l

def sic(l1,l2):
    if len(l1) < len(l2):
        for i in range(len(l1)):
            if l1[i] in l2:
                return 1
    else:
        for i in range(len(l2)):
            if l2[i] in l1:
                return 1
    return 0

i = int(input())
l = list(set(divisor(i)))
p = 0
for j in range(len(l)):
    if sic(list(str(l[j])),list(str(i))) == 1:
        p += 1

print(p)