#!/bin/python
# https://www.hackerrank.com/challenges/find-digits/problem
# by oz

import sys


t = int(raw_input().strip())

def checkDigits(number):
    lista=map(int,str(number))
    counter=0
    
    for i in lista:
        if i !=0 and number%i==0 :
            counter+=1
                
    return str(counter)
            
    

for a0 in xrange(t):
    n = int(raw_input().strip())
    #print "hola"
    print (checkDigits(n))
b5c338e17bc14a6c61f6816e02a23b938b28b9b0
<mask token>


def checkDigits(number):
    lista = map(int, str(number))
    counter = 0
    for i in lista:
        if i != 0 and number % i == 0:
            counter += 1
    return str(counter)


<mask token>

<mask token>


def checkDigits(number):
    lista = map(int, str(number))
    counter = 0
    for i in lista:
        if i != 0 and number % i == 0:
            counter += 1
    return str(counter)


for a0 in xrange(t):
    n = int(raw_input().strip())
    print(checkDigits(n))

<mask token>
t = int(raw_input().strip())


def checkDigits(number):
    lista = map(int, str(number))
    counter = 0
    for i in lista:
        if i != 0 and number % i == 0:
            counter += 1
    return str(counter)


for a0 in xrange(t):
    n = int(raw_input().strip())
    print(checkDigits(n))

import sys
t = int(raw_input().strip())


def checkDigits(number):
    lista = map(int, str(number))
    counter = 0
    for i in lista:
        if i != 0 and number % i == 0:
            counter += 1
    return str(counter)


for a0 in xrange(t):
    n = int(raw_input().strip())
    print(checkDigits(n))

#!/bin/python
# https://www.hackerrank.com/challenges/find-digits/problem
# by oz

import sys


t = int(raw_input().strip())

def checkDigits(number):
    lista=map(int,str(number))
    counter=0
    
    for i in lista:
        if i !=0 and number%i==0 :
            counter+=1
                
    return str(counter)
            
    

for a0 in xrange(t):
    n = int(raw_input().strip())
    #print "hola"
    print (checkDigits(n))