Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a).


-----Input-----

The first line contains integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 9). The i-th of the following n lines contains integer a_{i} without leading zeroes (1 ≤ a_{i} ≤ 10^9).


-----Output-----

Print a single integer — the number of k-good numbers in a.


-----Examples-----
Input
10 6
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560

Output
10

Input
2 1
1
10

Output
1

Difficulty: interview

Starter code:

Solutions:
def check(s,k):
    for i in range(k+1):
        if chr(ord('0')+i) not in s: 
            return False
    return True


n, k = map(int,input().split())
ans = 0
for i in range(n):
    ss = input()
    if check(ss,k):
        ans +=1
print(ans)

def valid(x,k):
    for item in L:
        if(item not in x):
            return False
    return True

n,k=list(map(int,input().split()))
ans=0
L=[]
for i in range(k+1):
    L.append(str(i))
for i in range(n):
    x=input()
    if(valid(x,k)):
        ans+=1
print(ans)


n,m=map(int,input().split())
ans = 0
for i in range(n):
    a = input().strip()
    c = [True]*(m+1)
    for k in a:
        if k<=str(m):
            c[int(k)] = False
    if c.count(True)==0:
        ans+=1
print(ans)

n, k = list(map(int, input().split()))
b = {str(i) for i in range(k+1)}
cnt = 0
for i in range(n):
    a = set(input())
    if a >= b: cnt += 1

print(cnt)



def check(a, k):
    used = [False for i in range(10)]
    while a != 0:
        used[a % 10] = True
        a //= 10
    return sum(used[:k + 1]) == k + 1

n, k = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = int(input())
    if check(a, k):
        cnt += 1
print(cnt)


n, k = map(int, input().split())
s = 0
o = 1
b=''
for i in range(k+1):
    b += str(i)
for i in range(n):
    o=1
    a = input()
    for j in b:
        if not j in a:
            o = 0
    if o==1:
        s+=1
print(s)

n, k = list(input().split())
res_n_i = 0
res = 0       
for i in range(int(n)):
    n_i = input()
    for j in range(int(k) + 1):
        if str(j) in n_i:
            res_n_i += 1
        else:
            res_n_i = 0
            break
        if res_n_i == int(k) + 1:
            res += 1
            res_n_i = 0            
print(res)


n, k = list(input().split())
res_n_i = 0
res = 0 
for i in range(int(n)):
    n_i = input()
    for j in range(int(k) + 1):
        if str(j) in n_i:
            res_n_i += 1
        else:
            res_n_i = 0
            break
        if res_n_i == int(k) + 1:
            res += 1
            res_n_i = 0 
print(res) 

import sys
n, k = list(map(int, sys.stdin.readline().split()))
count = 0
while n > 0 :
    num = input()
    i = 0
    while i <= k :
        if str(i) not in num :
            break;
        i += 1
    if i > k:   
        count += 1
    n -= 1
print(count)


line = input()

integers = [int(i) for i in line.split()]
n = integers[0]
k = integers[1]

toTest = []
for i in range(n):
    line = input()
    toTest.append(line)

def test(num, n):
    arr = [0]*(10)
    goal = [1]*(n+1)
    for i in range(10, n+1, -1):
        goal.append(0)
    for i in range(len(num)):
        if goal[int(num[i])] == 1:
            arr[int(num[i])] = 1
    if arr == goal:
        return 1
    else:
        return 0

total = 0
for num in toTest:
    total += test(num, k)

print(total)


3

def readln(): return tuple(map(int, input().split()))

n, k = readln()
ans = 0
for _ in range(n):
    v = set(map(int, list(input())))
    fl = True
    for i in range(k + 1):
        if i not in v:
            fl = False
    ans += fl
print(ans)


__author__ = 'Lipen'

def actions(n,k,a):
	answer = 0
	r = list(range(k+1))

	for i in a:
		if all(x in list(set(i)) for x in r):
			answer+=1

	return answer

def main():
	n, k = list(map(int, input().split()))
	a = []
	for i in range(n):
		a.append(list(map(int, input())))

	print(actions(n,k,a))

def __starting_point(): main()
__starting_point()

n, k = list(map(int, input().split()))
kset = {str(i) for i in range(k+1)}
myans = 0
for i in range(n):
    if kset <= set(input()):
        myans += 1
print(myans)


array2=input("").split(' ')
summ=0
array=list()
for t in range (0,int(array2[0])):
    g=input("")
    array.append(g)
if (int(array2[1])==0):
    for b in range (0,int(array2[0])):
        if '0' in array[b]:
            summ=summ+1
       

    print(summ)
if (int(array2[1])==1):
    for c in range (0,int(array2[0])):
        if '0' in array[c] and '1' in array[c]:
            summ=summ+1
    print(summ)
if (int(array2[1])==2):
    for d in range (0,int(array2[0])):
        if '0' in array[d] and '1' in array[d] and '2' in array[d]:
            summ=summ+1
    print(summ)
if (int(array2[1])==3):
    for e in range (0,int(array2[0])):
        if '0' in array[e] and '1' in array[e] and '2' in array[e] and '3' in array[e]:
            summ=summ+1
    print(summ)
if (int(array2[1])==4):
    for f in range (0,int(array2[0])):
        if '0' in array[f] and '1' in array[f] and '2' in array[f] and '3' in array[f] and '4' in array[f]:
            summ=summ+1
    print(summ)
if (int(array2[1])==5):
    for g in range (0,int(array2[0])):
        if '0' in array[g] and '1' in array[g] and '2' in array[g] and '3' in array[g] and '4' in array[g] and '5' in array[g]:
            summ=summ+1
    print(summ)
if (int(array2[1])==6):
    for h in range (0,int(array2[0])):
        if '0' in array[h] and '1' in array[h] and '2' in array[h] and '3' in array[h] and '4' in array[h] and '5' in array[h] and '6' in array[h]:
            summ=summ+1
    print(summ)
if (int(array2[1])==7):
     for i in range (0,int(array2[0])):
                if '0' in array[i] and '1' in array[i] and '2' in array[i] and '3' in array[i] and '4' in array[i] and '5' in array[i] and '6' in array[i] and '7' in array[i]:
                    summ=summ+1
     print(summ)
if (int(array2[1])==8):
    for j in range (0,int(array2[0])):
        if '0' in array[j] and '1' in array[j] and '2' in array[j] and '3' in array[j] and '4' in array[j] and '5' in array[j] and '6' in array[j] and '7' in array[j] and '8' in array[j]:
            summ=summ+1
    print(summ)
if (int(array2[1])==9):
    for k in range (0,int(array2[0])):
        if '0' in array[k] and '1' in array[k] and '2' in array[k] and '3' in array[k] and '4' in array[k] and '5' in array[k] and '6' in array[k] and '7' in array[k] and '8' in array[k] and '9' in array[k]:
            summ=summ+1
    print(summ)
            
            


#!/usr/bin/env python3

n, k = tuple(map(int, input().split()))
a = []
for i in range(n):
    a.append(input())

r = 0
for s in a:
    f = True
    for i in range(k + 1):
        if str(i) not in s:
            f = False
            break
    if f:
        r = r + 1

print(r)


n,k=list(map(int,input().split()))
def good(n,k):
    l=[0]*(k+1)
    while(n>0):
        num=n%10
        n=n//10
        if(num<=k):
            l[num]+=1
    for i in l:
        if(i==0):
            return False
    return True
c=0
for i in range(n):
    num=int(input())
    if(good(num,k)):
        c=c+1
print(c)
    


n,k = list(map(int,input().split()))
ans = 0
for i in range(n):
    a = input().strip()
    c = [True] * (k + 1)
    for j in a:
        if j <= str(k):
            c[int(j)] = False
    if c.count(True) == 0 :
        ans += 1
print(ans)
    


n, k = map(int, input().split())
t = [input() for i in range(n)]
for i in '0123456789'[: k + 1]: t = [j for j in t if i in j]
print(len(t))

n, k = map(int, input().split())
ris = 0
for cont in range(0,n):
    num = input()
    l = True
    for tmp in range(0, k+1):
        if (str(tmp) in num) is False:
            l = False
            break
    if l:
        ris += 1
print(ris)

def all_zero(mas):
    for i in mas:
        if i != 0: return False
    return True

I = [int(i) for i in input().split()]
n, k = I[0], I[1]
ans = 0
for i in range(n):
    pretender = input()
    k_mas = [1]*(k+1)
    for digit in pretender:
        if int(digit) <= k: k_mas[int(digit)] = 0
    if all_zero(k_mas): ans += 1
print(ans)

x = list(map(int, input().split()))
n = x[0]
k = x[1]
ans = 0

for i in range(n):
	a = input()
	used = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for c in a:
		used[int(c)] = 1
	cnt = 0
	for c in range(0, k + 1):
		cnt += used[c]
	if (cnt == k + 1):
		ans += 1
print(ans)





n, k = map(int, input().split())

def IsGoodNumber(number):
  return "0123456789"[:k + 1] in ''.join(sorted(set(number)))

numbers = [input() for _ in range(n)]
print(sum(1 for number in numbers if IsGoodNumber(number)))

n, k = map(int, input().split())
nums = [input() for i in range(n)]
nums = [(nums.count(x), sorted(map(int,set(x)))) for x in set(nums)]

k_digs = list(range(0, k+1))
res = 0

for (c, x) in nums:
    if sorted(set(x) & set(k_digs)) == k_digs:
       res += c

print(res)

n, k = map(int, input().split())
kset = {str(i) for i in range(k+1)}
myans = 0
for i in range(n):
    if kset <= set(input()):
        myans += 1
print(myans)

def g(a, k):
    if a == 0:
        return k == 0
    s = set()
    while a > 0:
        if a % 10 <= k:
            s.add(a % 10)
        a //= 10
    return len(s) == k + 1

n, k = (int(x) for x in input().split())
print(sum(g(int(input()), k) for i in range(n)))