An integer $\boldsymbol{d}$ is a divisor of an integer $n$ if the remainder of $n\div d=0$.  

Given an integer, for each digit that makes up the integer determine whether it is a divisor.  Count the number of divisors occurring within the integer.  

Example 

$n=124$  

Check whether $1$, $2$ and $4$ are divisors of $124$.  All 3 numbers divide evenly into $124$ so return $3$.  

$n=111$  

Check whether $1$, $1$, and $1$ are divisors of $\mbox{111}$.  All 3 numbers divide evenly into $\mbox{111}$ so return $3$.  

$n=10$  

Check whether $1$ and $0$ are divisors of $10$.  $1$ is, but $0$ is not.  Return $1$.  

Function Description

Complete the findDigits function in the editor below.   

findDigits has the following parameter(s):

int n: the value to analyze  

Returns  

int: the number of digits in $n$ that are divisors of $n$  

Input Format

The first line is an integer, $\boldsymbol{\boldsymbol{t}}$, the number of test cases. 

The $\boldsymbol{\boldsymbol{t}}$ subsequent lines each contain an integer, $n$.  

Constraints

$1\leq t\leq15$ 

$0<n<10^9$

Sample Input
2
12
1012

Sample Output
2
3

Explanation

The number $12$ is broken into two digits, $1$ and $2$. When $12$ is divided by either of those two digits, the remainder is $0$ so they are both divisors.

The number $\textbf{1012}$ is broken into four digits, $1$, $0$, $1$, and $2$. $\textbf{1012}$ is evenly divisible by its digits $1$, $1$, and $2$, but it is not divisible by $0$ as division by zero is undefined.

Difficulty: EASY

Solutions:
def func(A):
	return len([1 for i in str(A) if i != '0' and A % int(i) == 0])
for t in range(int(input())):
	print(func(int(input())))


T = int(input())
for i in range(T):
	st = input()
	num = int(st)
	count = 0
	for i in range(len(st)):
		pos = int(st[i])
		if pos == 0:
			continue
		if num % pos == 0:
			count += 1
	print(count)


def SOLVE():
	n = input()
	l = int(n)
	L = len(n)
	ans = 0
	for i in range(0, L):
		if n[i] == '0':
			continue
		elif l % int(n[i]) == 0:
			ans += 1
	print(ans)
x = int(input())
while x:
	x -= 1
	SOLVE()


T = int(input())
for t in range(0, T):
	sn = input().strip()
	n = int(sn)
	c = 0
	for sd in sn:
		d = int(sd)
		if d > 0 and n % d == 0:
			c += 1
	print(c)


import sys
T = int(sys.stdin.readline())
while T > 0:
	counter = 0
	N = sys.stdin.readline().replace('\n', '')
	(digits, N) = (list(N), int(N))
	for digit in digits:
		digit = int(digit)
		if digit != 0 and N % int(digit) == 0:
			counter += 1
	print(counter)
	T -= 1


T = int(input())
OUT = []
for t in range(0, T):
	count = 0
	N = int(input())
	s = str(N)
	for i in range(0, len(s)):
		if int(s[i]) != 0:
			if N % int(s[i]) == 0:
				count = count + 1
	OUT.append(count)
for o in OUT:
	print(o)


n = int(input())
for i in range(0, n):
	s = input()
	x = int(s)
	ans = 0
	for c in s:
		d = int(c)
		if d != 0 and x % d == 0:
			ans += 1
	print(ans)


n = int(input())
for i in range(n):
	num_str = input().strip()
	num = int(num_str)
	count = 0
	for char in num_str:
		char_digit = int(char)
		if char_digit != 0 and num % char_digit == 0:
			count += 1
	print(count)


import sys

def find_it():
	iter = sys.stdin.readline()
	for z in range(0, int(iter)):
		num = sys.stdin.readline()
		num = num.strip()
		result = 0
		for i in range(0, len(num)):
			if int(num[i]) != 0:
				if int(num) % int(num[i]) == 0:
					result += 1
		print(result)

def main():
	find_it()
main()


NumberOfCases = int(input())
for Cases in range(NumberOfCases):
	Total = 0
	Number = input()
	for Digit in Number:
		if Digit != str(0):
			if int(Number) % int(Digit) == 0:
				Total += 1
	print(Total)


import sys
tests = int(sys.stdin.readline().strip())
for t in range(tests):
	digitsFound = {}
	digLast = 0
	sumMod3 = 0
	digBeforeLast = 0
	mod7 = 0
	digBefBeforeLast = 0
	sumMod9 = 0
	c = sys.stdin.read(1)
	while c != '\n' and len(c):
		c = int(c)
		if c not in digitsFound:
			digitsFound[c] = 0
		digitsFound[c] += 1
		(digBefBeforeLast, digBeforeLast, digLast) = (digBeforeLast, digLast, c)
		sumMod3 = (sumMod3 + c) % 3
		mod7 = (mod7 * 10 + c) % 7
		sumMod9 = (sumMod9 + c) % 9
		c = sys.stdin.read(1)
	result = 0
	for (d, amount) in digitsFound.items():
		if d == 1:
			result += amount
		elif d == 2:
			if digLast % 2 == 0:
				result += amount
		elif d == 3:
			if not sumMod3:
				result += amount
		elif d == 4:
			if (digBeforeLast * 10 + digLast) % 4 == 0:
				result += amount
		elif d == 5:
			if digLast % 5 == 0:
				result += amount
		elif d == 6:
			if digLast % 2 == 0 and (not sumMod3):
				result += amount
		elif d == 7:
			if not mod7:
				result += amount
		elif d == 8:
			if (digBefBeforeLast * 100 + digBeforeLast * 10 + digLast) % 8 == 0:
				result += amount
		elif d == 9:
			if not sumMod9:
				result += amount
	print(result)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	N = int(sys.stdin.readline())
	digits = list(map(int, str(N)))
	print(sum((digits.count(k) for k in range(1, 10) if k in digits and N % k == 0)))


t = int(input())
for j in range(0, t):
	n = int(input())
	rs = str(n)
	count = 0
	for i in range(0, len(rs)):
		akh = int(rs[i])
		if akh != 0:
			if n % akh == 0:
				count = count + 1
	print(count)


t = int(input())
for i in range(0, t):
	n = int(input())
	m = n
	c = 0
	while n > 0:
		try:
			if m % (n % 10) == 0:
				c += 1
		except ZeroDivisionError:
			c = c
		n = n // 10
	print(c)


TotalTests = input()
TestValuesArray = []
AnswersArray = []
for i in range(int(TotalTests)):
	TestValue = input()
	TestValuesArray.append(int(TestValue))
	AnswersArray.append('')
for i in range(0, len(TestValuesArray)):
	CurrentValue = TestValuesArray[i]
	CurrentValueString = str(CurrentValue)
	Counter = 0
	for j in range(0, len(CurrentValueString)):
		if int(CurrentValueString[j]) != 0:
			if TestValuesArray[i] % int(CurrentValueString[j]) == 0:
				Counter += 1
	AnswersArray[i] = Counter
for i in range(0, len(AnswersArray)):
	print(AnswersArray[i])


t = int(input())
for u in range(t):
	line = input()
	n = int(line)
	total = 0
	for i in range(len(line)):
		o = int(line[i])
		if o != 0 and n % o == 0:
			total += 1
	print(total)


for i in range(int(input())):
	x = input()
	no = int(x)
	ans = 0
	for i in x:
		try:
			if no % int(i) == 0:
				ans += 1
		except:
			pass
	print(ans)


t = int(input())
for i in range(t):
	num = input()
	ret = 0
	for d in num:
		if int(d) > 0 and int(num) % int(d) == 0:
			ret += 1
	print(ret)


def noDivide(strDigit):
	lenDigit = len(strDigit)
	j = 0
	intDigit = int(strDigit)
	counter = 0
	while j < lenDigit:
		if int(strDigit[j]) > 0:
			if intDigit % int(strDigit[j]) == 0:
				counter = counter + 1
		j = j + 1
	return counter
t = int(input())
i = 0
digits = list()
oupt = list()
temp = ''
while i < t:
	temp = input()
	digits.append(temp)
	oupt.append(noDivide(temp))
	i = i + 1
i = 0
while i < t:
	print(oupt[i])
	i = i + 1


def find_digits(x):
	print(sum((not x % int(c) for c in str(x) if int(c))))
T = int(input())
for _ in range(T):
	x = int(input())
	find_digits(x)


import sys
next(sys.stdin)
for line in sys.stdin:
	line = line.strip()
	n = int(line)
	print(sum(map(lambda x: 0 if x == '0' else n % int(x) == 0, line)))


t = int(input())
total = 0
for i in range(0, t):
	val = int(input())
	tmp_val = val
	while tmp_val > 0:
		last_digit = tmp_val % 10
		tmp_val = int(tmp_val / 10)
		if last_digit != 0:
			if val % last_digit == 0:
				total += 1
	print(total)
	total = 0


t = int(input())
for i in range(0, t):
	val = int(input())
	dig = len(str(val))
	temp_val = val
	count = 0
	itr = 0
	factor = 10
	while itr < dig:
		temp = temp_val % factor
		if temp == 0:
			pass
		elif val % temp == 0:
			count += 1
		itr += 1
		temp_val = int(temp_val / 10)
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	m = n
	c = 0
	while m:
		d = m % 10
		if d and n % d == 0:
			c += 1
		m //= 10
	print(c)


numtests = int(input())
tests = []
for i in range(numtests):
	tests.append(int(input()))
for i in range(numtests):
	number = tests[i]
	count = 0
	x = number
	while x:
		digit = x % 10
		if digit != 0 and number % digit == 0:
			count = count + 1
		x = x // 10
	print(count)


a = int(input())
for x in range(0, a):
	b = input()
	c = len(b)
	f = [] * c
	d = int(b)
	k = 0
	for y in range(0, c):
		if int(b[y]) != 0 and d % int(b[y]) == 0:
			k = k + 1
	print(k)


T = int(input())
for t in range(T):
	n = int(input())
	nn = n
	count = 0
	while nn > 0:
		(nn, nr) = (nn // 10, nn % 10)
		if nr != 0 and n % nr == 0:
			count += 1
	print(count)


t = int(input())
for i in range(t):
	s = input()
	(n, c) = (int(s), 0)
	for x in s:
		if x != '0' and n % int(x) == 0:
			c += 1
	print(c)


import sys

def digit_division(n):
	digit_list = [str(i) for i in range(1, 10) if n % i == 0]
	return len([dig for dig in str(n) if dig in digit_list])

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		print(digit_division(n))
main()


for _ in range(int(input())):
	source = input()
	number = int(source)
	digits = set(source)
	answer = 0
	for digit in digits:
		if digit != '0' and number % int(digit) == 0:
			answer += source.count(digit)
	print(answer)


t = int(input())
c = 0
while t > c:
	s = input()
	count = 0
	for i in range(len(s)):
		if int(s[i]) != 0:
			if int(s) % int(s[i]) == 0:
				count += 1
	print(count)
	c += 1


for i in range(int(input())):
	numberString = input()
	number = int(numberString)
	count = 0
	for digit in numberString:
		digitString = int(digit)
		if digitString > 0 and number % digitString == 0:
			count = count + 1
	print(count)


def num_div(n):
	count = 0
	toStringN = str(n)
	for d in toStringN:
		if int(d) != 0 and n % int(d) == 0:
			count += 1
	return count
T = int(input())
testCases = list()
for i in range(T):
	testCases.append(int(input()))
for testCase in testCases:
	print(num_div(testCase))


import sys
data = sys.stdin.readlines()
lines = int(data[1])
count = 0

def warning(*objs):
	print('WARNING: ', *objs, file=sys.stderr)
for n in data[1:]:
	num = int(n)
	digits = list(n)
	for d in digits:
		if d.isnumeric():
			digit = int(d)
			if digit != 0 and num % digit == 0:
				count += 1
	print(count)
	count = 0


T = int(input())
for i in range(0, T):
	N = input()
	l = list(N)
	count = 0
	for j in l:
		if int(j) != 0:
			if int(N) % int(j) == 0:
				count += 1
	print(count)


t = int(input())
for j in range(t):
	x = input()
	sum = 0
	for i in x:
		try:
			if int(x) % int(i) == 0:
				sum += 1
		except:
			sum += 0
	print(sum)


T = int(input())
for t in range(T):
	N = int(input())
	ret = 0
	for digit in str(N):
		if digit == '0':
			continue
		if N % int(digit) == 0:
			ret += 1
	print(ret)


T = int(input())
for t in range(T):
	i_value = int(input())
	c_value = [float(i) for i in str(i_value)]
	total = 0
	for c in c_value:
		if c == 0:
			continue
		if i_value / c % 1 == 0:
			total += 1
	print(total)


cases = int(input())
solutions = [0 for x in range(cases)]
for i in range(cases):
	j = input()
	n = [int(x) for x in j]
	j = int(j)
	for k in n:
		if k != 0:
			if j % k == 0:
				solutions[i] += 1
for xyz in solutions:
	print(xyz)


t = int(input())
for each_case in range(0, t):
	count = 0
	num = input()
	for each_num in num:
		if int(each_num) != 0:
			if int(num) % int(each_num) == 0:
				count = count + 1
	print(count)


def prog():
	for i in range(int(input())):
		number = abs(int(input()))
		count = 0
		for num in list(str(number)):
			if int(num) != 0 and number / int(num) == int(number / int(num)):
				count += 1
		print(count)
prog()


t = int(input())
for i in range(t):
	c = 0
	n = int(input())
	s = str(n)
	for i in range(len(s)):
		if s[i] != '0':
			if n % int(s[i]) == 0:
				c += 1
	print(c)


N = int(input())
while N:
	N -= 1
	n = input()
	print(sum([1 for d in n if int(d) != 0 and int(n) % int(d) == 0]))


T = int(input())
for i in range(0, T):
	num = int(input())
	a = num
	res = 0
	while num != 0:
		dig = num % 10
		num = int(num / 10)
		if dig != 0 and a % dig == 0:
			res = res + 1
	print(res)


import sys
T = int(input())
for _ in range(T):
	N = [int(x) for x in sys.stdin.readline().strip()]
	N = [0] * (3 - len(N) % 3) + N
	(n, answer) = (len(N), 0)
	assert n % 3 == 0
	f = [0] * 10
	for x in N:
		f[x] += 1
	answer += f[1]
	if N[n - 1] % 2 == 0:
		answer += f[2]
	if N[n - 1] % 5 == 0:
		answer += f[5]
	if (N[n - 2] * 10 + N[n - 1]) % 4 == 0:
		answer += f[4]
	if (N[n - 3] * 100 + N[n - 2] * 10 + N[n - 1]) % 8 == 0:
		answer += f[8]
	s = sum(N)
	if s % 3 == 0:
		answer += f[3]
		if N[n - 1] % 2 == 0:
			answer += f[6]
	if s % 9 == 0:
		answer += f[9]
	(sign, s) = (1, 0)
	for i in range(n - 1, -1, -3):
		s += sign * (N[i - 2] * 100 + N[i - 1] * 10 + N[i])
		sign *= -1
	if s % 7 == 0:
		answer += f[7]
	print(answer)


t = int(input())
for testCase in range(t):
	numStr = input()
	num = int(numStr)
	total = 0
	for digit in numStr:
		if digit != '0' and num % int(digit) == 0:
			total += 1
	print(total)


T = int(input())
for _ in range(T):
	str_in = input()
	test_num = int(str_in)
	parts = list(str_in)
	count = 0
	for i in range(len(parts)):
		if int(parts[i]) != 0:
			if test_num % int(parts[i]) == 0:
				count += 1
	print(count)


def check_divisibility(list_numbers):
	for string in list_numbers:
		count = 0
		for char in str(string):
			if int(char) != 0:
				if string % int(char) == 0:
					count = count + 1
		print(count)
no_of_cases = int(input())
if no_of_cases >= 1 and no_of_cases <= 15:
	test_numbers = []
	for i in range(1, no_of_cases + 1):
		input_value = int(input())
		if input_value > 0 and input_value < 10 ** 10:
			test_numbers.append(input_value)
	check_divisibility(test_numbers)


n = int(input())
for i in range(n):
	v = input()
	v1 = int(v)
	count = 0
	for a in v:
		if int(a) != 0:
			if v1 % int(a) == 0:
				count += 1
	print(count)


n = int(input())
cases = [input() for i in range(n)]

def digits(n):
	count = 0
	digits = [int(x) for x in n if x != '0']
	n = int(n)
	for digit in digits:
		if n % digit == 0:
			count += 1
	return count
results = [digits(x) for x in cases]
print('\n'.join((str(x) for x in results)))


T = input()
T = int(T)
while T >= 1:
	n = input()
	n = int(n)
	k = int(n)
	count = 0
	while n >= 1:
		if n % 10 == 0:
			n = int((n - n % 10) / 10)
			continue
		if k % (n % 10) == 0:
			count += 1
		n = int((n - n % 10) / 10)
	print(count)
	T -= 1


test_cases = int(input())
while test_cases > 0:
	test_cases -= 1
	s = input()
	n = int(s)
	res = 0
	for char in s:
		if int(char) != 0 and n % int(char) == 0:
			res += 1
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	temp = n
	count = 0
	while temp > 0:
		rem = temp % 10
		if rem != 0 and n % rem == 0:
			count = count + 1
		temp = temp // 10
	print(count)


test = int(input())
for i in range(test):
	n = int(input())
	flag = 0
	temp = n
	while n > 0:
		if n % 10 != 0:
			if temp % (n % 10) == 0:
				flag += 1
		elif n % 10 == 0:
			pass
		n = int(n / 10)
	print(flag)


T = int(input())
for i in range(T):
	n_s = input()
	n_c = 0
	for n_s_i in n_s:
		if n_s_i == '0':
			continue
		if int(n_s) % int(n_s_i) == 0:
			n_c += 1
	print(n_c)


for _ in range(int(input())):
	s = input()
	n = int(s)
	print(sum((n % d == 0 for d in map(int, s) if d != 0)))


LST = [lambda x: False, lambda x: True, lambda x: x & 1 == 0, lambda x: sum(map(int, str(x))) % 3 == 0, lambda x: int(''.join(str(x)[-2:])) % 4 == 0, lambda x: int(str(x)[-1]) == 5 or int(str(x)[-1]) == 0, lambda x: LST[2](x) and LST[3](x), lambda x: x % 7 == 0, lambda x: int(''.join(str(x)[-3:])) % 8 == 0, lambda x: sum(map(int, str(x))) % 9 == 0]
T = int(input())
for i in range(T):
	N = int(input())
	count = 0
	for x in map(int, str(N)):
		if LST[x](N):
			count = count + 1
	print(count)


T = int(input())
for i in range(0, T):
	count = 0
	N = int(input())
	for i in list(str(N)):
		if int(i) == 0:
			continue
		elif N % int(i) == 0:
			count += 1
	print(count)


T = int(input())

def solve():
	count = 0
	s = input()
	i = int(s)
	for c in s:
		if int(c) > 0 and i % int(c) == 0:
			count += 1
	print(count)
for i in range(T):
	solve()


for t in range(int(input())):
	n = int(input())
	l = list(str(n))
	c = 0
	for i in range(len(l)):
		try:
			if n % int(l[i]) == 0:
				c += 1
		except ZeroDivisionError:
			continue
	print(c)


R = int(input())
for i in range(R):
	count = 0
	string = str(input())
	num = int(string)
	for char in string:
		digit = int(char)
		if digit != 0:
			if num % digit == 0:
				count += 1
	print(count)


t = int(input())
while t > 0:
	n = int(input())
	temp = n
	digits = [0] * 10
	while temp > 0:
		digit = temp % 10
		digits[digit] = digits[digit] + 1
		temp = temp // 10
	result = 0
	iter = 1
	while iter < 10:
		if n % iter == 0:
			result = result + digits[iter]
		iter = iter + 1
	print(result)
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	res = 0
	for d in [int(tmp) for tmp in str(n)]:
		if d and n % d == 0:
			res += 1
	print(res)


for t in range(int(input())):
	n = str(input())
	y = int(n)
	count = 0
	for x in n:
		if int(x) == 0:
			count += 0
		elif y % int(x) == 0:
			count += 1
	print(count)


T = int(input())
for i in range(0, T):
	N = input()
	answer = 0
	number = int(N)
	for x in N:
		digit = int(x)
		if digit != 0 and number % digit == 0:
			answer += 1
	print(answer)


t = int(input())
for idx in range(t):
	n = int(input())
	divisors = 0
	for digit in str(n):
		if int(digit) == 0:
			continue
		if n % int(digit) == 0:
			divisors += 1
	print(divisors)


T = int(input())
for q in range(T):
	n = int(input())
	digits = [int(i) for i in str(n) if i != '0']
	cnt = 0
	for dig in digits:
		if n % dig == 0:
			cnt += 1
	print(cnt)


t = int(input())
result = []
for i in range(0, t):
	n = int(input())
	no = str(n)
	count = 0
	for j in range(0, len(no)):
		if int(no[j]) != 0 and n % int(no[j]) == 0:
			count = count + 1
	result.append(count)
for i in range(0, len(result)):
	print(result[i])


lst = []
x = int(input())
while x > 0:
	lst.append(input())
	x -= 1
for z in lst:
	y = 0
	a = str(z)
	for num in a:
		if int(num) != 0 and int(z) % int(num) == 0:
			y += 1
	print(y)


num_tests = int(input())
for i in range(num_tests):
	num = input()
	int_num = int(num)
	count = 0
	for i in num:
		if i != '0' and int_num % int(i) == 0:
			count += 1
	print(count)


T = int(input())
cases = [int(input()) for _ in range(T)]
for case in cases:
	count = 0
	rem = case
	while rem > 0:
		if rem % 10 != 0 and case % (rem % 10) == 0:
			count += 1
		rem //= 10
	print(count)


def how_many(num):
	count = 0
	num1 = list(map(int, str(num)))
	for each in num1:
		if each == 0:
			continue
		if num % each == 0:
			count += 1
	return count
T = int(input())
for i in range(0, T):
	num = int(input())
	ans = how_many(num)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	nlist = list(map(int, list(str(n))))
	nlist = [j for j in nlist if j > 0]
	divlist = [1 for j in nlist if n % j == 0]
	print(sum(divlist))


for _ in range(int(input())):
	n = input()
	v = int(n)
	print(len([x for x in map(int, n) if x is not 0 and v % x is 0]))


def get_result(n):
	r = 0
	p = n
	while n > 0:
		if n % 10:
			if not p % (n % 10):
				r += 1
		n //= 10
	return r
t = int(input())
for _ in range(t):
	print(int(get_result(int(input()))))


def solve(n):
	count = 0
	digits = list(map(int, str(n)))
	for digit in digits:
		if digit != 0 and n % digit == 0:
			count += 1
	return count
T = int(input())
for _ in range(T):
	print(solve(int(input())))


T = int(input())

def findDigits(num):
	res = 0
	for i in num:
		if int(i) != 0:
			if int(num) % int(i) == 0:
				res = res + 1
	return res
i = 0
while i < T:
	arg = input()
	print(findDigits(arg))
	i = i + 1


def list_of_digit(n):
	res = []
	while n != 0:
		if n % 10 != 0:
			res.append(n % 10)
		n = int(n / 10)
	return res

def compute_result(n):
	digits = list_of_digit(n)
	num = 0
	for i in digits:
		if n % i == 0:
			num += 1
	return num
t = int(input())
res = []
for i in range(t):
	res.append(compute_result(int(input())))
for i in res:
	print(i)


__author__ = 'jeffmcgraw'

def main():
	num_tests = int(input())
	for a in range(num_tests):
		output = 0
		test_line = input()
		test_value = int(test_line)
		for b in test_line:
			if b != '0' and test_value % int(b) == 0:
				output += 1
		print(output)
main()


cases = int(input())
for _ in range(cases):
	n_str = input()
	n = int(n_str)
	divides = {'0': False}
	for i in range(1, 10):
		divides[str(i)] = n % i == 0
	count = 0
	for c in n_str:
		if divides[c]:
			count += 1
	print(count)


def dignum(num):
	sa = 0
	for dig in str(num):
		if dig != '0':
			if num % int(dig) == 0:
				sa += 1
	return sa
tcs = int(input())
for tc in range(tcs):
	sa = int(input())
	print(dignum(sa))


T = int(input())
for _ in range(T):
	N = int(input())
	digits = 0
	n = N
	while n:
		d = n % 10
		if d and N % d == 0:
			digits += 1
		n //= 10
	print(digits)


for t in range(int(input())):
	n = int(input())
	digits = str(n)
	count = 0
	for digit in digits:
		count += n % int(digit) == 0 if digit != '0' else 0
	print(count)


T = int(input())
for i in range(T):
	N = int(input())
	A = str(N)
	count = 0
	for i in range(len(str(N))):
		if A[i] != '0':
			if N % int(A[i]) == 0:
				count += 1
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	digits = [int(i) for i in str(n) if int(i) != 0]
	print(sum([1 for digit in digits if n % digit == 0]))


def divdig(x):
	divs = 0
	s = str(x)
	for char in s:
		cand = int(char)
		if cand != 0 and x % cand == 0:
			divs += 1
	return divs

def runner():
	cases = int(input())
	for i in range(0, cases):
		x = int(input())
		print(divdig(x))
runner()


cases = int(input())
for case in range(cases):
	total = 0
	number = input()
	digits = list(number)
	for digit in digits:
		if int(digit) == 0:
			pass
		elif int(number) % int(digit) == 0:
			total += 1
	print(total)


cases = int(input())
for case in range(cases):
	string = input().strip()
	num = int(string)
	sum_ = 0
	for char in string:
		if char == '0':
			continue
		if num % int(char) == 0:
			sum_ += 1
	print(sum_)


def main():
	cases = int(input())
	for i in range(cases):
		result = 0
		number = input()
		n = int(number)
		for a in range(len(number)):
			if number[a] != '0':
				if n % int(number[a]) == 0:
					result += 1
		print(result)
main()


__author__ = 'danielbaeck'
import math
t = int(input())
for i in range(t):
	n = input()
	num = int(n)
	cnt = 0
	for c in n:
		if int(c) != 0 and num % int(c) == 0:
			cnt += 1
	print(cnt)


def findDigits(number):
	digits = [int(x) for x in str(number)]
	division = []
	for i in range(1, 10):
		if number % i == 0:
			division.append(i)
	cnt = 0
	for x in division:
		cnt += digits.count(x)
	return cnt

def main():
	caseCnt = int(input())
	cases = []
	for i in range(0, caseCnt):
		cases.append(int(input()))
	for x in cases:
		print(findDigits(x))
main()


T = int(input())
for i in range(T):
	N = input()
	answer = 0
	last = int(N[-1:])
	sumOfAll = 0
	for j in range(len(N)):
		sumOfAll += int(N[j])
	last2 = int(N[-2:])
	last3 = int(N[-3:])
	num = int(N)
	s = str(num)
	while len(s) > 2:
		num = int(s[:-1]) - int(s[-1:]) * 2
		s = str(num)
	for j in range(len(N)):
		d = int(N[j])
		if d == 1:
			answer += 1
		elif d == 2 and last % 2 == 0:
			answer += 1
		elif d == 3 and sumOfAll % 3 == 0:
			answer += 1
		elif d == 4 and last2 % 4 == 0:
			answer += 1
		elif d == 5 and (last == 0 or last == 5):
			answer += 1
		elif d == 6 and last % 2 == 0 and (sumOfAll % 3 == 0):
			answer += 1
		elif d == 7 and num % 7 == 0:
			answer += 1
		elif d == 8 and last3 % 8 == 0:
			answer += 1
		elif d == 9 and sumOfAll % 9 == 0:
			answer += 1
	print(answer)


import sys
from math import floor

def ciffers(n):
	c = 0
	while 0 < n:
		n = floor(n / 10)
		c += 1
	return c
T = int(input())
numbers = [int(s.strip()) for s in sys.stdin.readlines()]
for n in numbers:
	c = ciffers(n)
	ans = 0
	for i in range(c):
		j = floor(n / 10 ** i) % 10
		if j != 0 and n % j == 0:
			ans += 1
	print(ans)


def count(t):
	d = t
	c = 0
	while d > 0:
		v = d % 10
		d //= 10
		if v != 0 and t % v == 0:
			c += 1
	return c
n = int(input())
for i in range(n):
	print(count(int(input())))


for _ in range(int(input())):
	number = int(input())
	exploded = list(map(int, list(str(number))))
	count = 0
	for digit in range(len(exploded)):
		try:
			if number % exploded[digit] == 0:
				count += 1
		except:
			pass
	print(count)


t = int(input())
while t > 0:
	n = int(input())
	c = 0
	k = n
	t = t - 1
	while k > 0:
		r = k % 10
		if r != 0 and n % r == 0:
			c = c + 1
		k = int(k / 10)
	print(c)


cases = int(input())
for case in range(cases):
	n = int(input())
	c = 0
	for num in str(n):
		if int(num) != 0 and n % int(num) == 0:
			c += 1
	print(c)


T = int(input())
for i in range(T):
	N = int(input())
	num = [int(x) for x in str(N)]
	evenly = 0
	for i in num:
		if i == 0:
			continue
		evenly += N % i == 0
	print(evenly)


n = int(input())
z = 0
while z < n:
	inpstr = str(input())
	inpint = int(inpstr)
	lis = list(inpstr)
	count = 0
	for x in lis:
		num = int(x)
		if num != 0:
			if inpint % num == 0:
				count += 1
	z += 1
	print(count)


T = int(input())
for i in range(T):
	Ns = input()
	N = int(Ns)
	count = 0
	for c in Ns:
		if c == '0':
			continue
		elif N % int(c) == 0:
			count += 1
	print(count)