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
from math import *
n = int(input())
l = []
c = 0
for i in range(1, floor(sqrt(n)) + 1):
    if n % i == 0:
        if n//i == i:
            l.append(i)
        else:
            l.append(n//i)
            l.append(i)
l2 = [0]*10
m = n
while m != 0:
    l2[m % 10] += 1
    m //= 10

for i in range(len(l)):
    e = l[i]
    flag = False
    l1 = [0]*10
    while e != 0:
        l1[e % 10] += 1
        e //= 10
    for _ in range(10):
        if l1[_] >= 1 and l2[_] >= 1:
            flag = True
    if flag:
        c += 1

print(c)
