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

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
(arrays, k) = list(input().split())
l = []
bad = 0
for i in range(int(arrays)):
	array = input()
	l.append(array)
for i in range(len(l)):
	for j in range(int(k) + 1):
		if not str(j) in l[i]:
			bad += 1
			break
print(len(l) - bad)


(n, k) = map(int, input().split())
s = set('0123456789'[:k + 1])
print(sum((set(input()) >= s for _ in range(n))))


(a, b) = map(int, input().split())
z = 0
e = 0
while z < a:
	n = input()
	h = 0
	while h <= b:
		if str(h) in n:
			h += 1
		else:
			e += 1
			break
	z += 1
print(a - e)


(n, k) = map(int, input().split())
arr = [False] * (k + 1)
c = 0
for i in range(n):
	n = input()
	for j in n:
		if int(j) > k:
			continue
		else:
			arr[int(j)] = True
	if arr.count(True) - 1 == k:
		c += 1
	arr = [False] * (k + 1)
print(c)


(n, k) = list(map(int, input().split()))
sol = 0
k_digts = [str(i) for i in range(k + 1)]
for _ in range(n):
	Ai = input()
	if not any((ch not in Ai for ch in k_digts)):
		sol += 1
print(sol)


(n, k) = map(int, input().split())
cn = 0
for i in range(n):
	num = input()
	tester = True
	for x in range(k + 1):
		tester = tester and str(x) in num
	cn += tester
print(cn)


lt = list(input().split())
(n, k) = (int(lt[0]), int(lt[1]))
r = 0
while n != 0:
	n -= 1
	D = {}
	s = input()
	for i in s:
		if int(i) <= k:
			D[int(i)] = 1
	if len(D) == k + 1:
		r += 1
print(r)


(n, k) = map(int, input().split())
ans = 0
for i in range(n):
	s = sorted(set(input()))
	if len(s) > k and s[k] == str(k):
		ans += 1
print(ans)


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)


alph = 'abcdefghijklmnopqrstuvwxyz'
(n, k) = map(int, input().split())
E = 0
for i in range(n):
	s = str(input())
	u = 0
	for j in range(0, k + 1):
		u += int(s.count(str(j)) != 0)
	if u == k + 1:
		E += 1
print(E)


def goodnumber(n, k):
	n = str(n)
	n1 = list(n)
	n2 = set(n1)
	op = list(n2)
	count = 0
	for i in op:
		if int(i) <= k:
			count += 1
	if count == k + 1:
		return True
	else:
		return False

def checker(t, k):
	ans = 0
	for i in range(t):
		n = int(input())
		if goodnumber(n, k):
			ans += 1
	print(ans)
(t, k) = map(int, input().split())
checker(t, k)


(n, k) = map(int, input().split())
ans = 0
lst1 = []
for i in range(0, k + 1):
	lst1.append(i)
while n > 0:
	n = n - 1
	t = int(input())
	lst = []
	f = 1
	c = 0
	while t > 0:
		s = t % 10
		lst.append(s)
		t = t // 10
	for i in lst1:
		if i in lst:
			c = c + 1
		else:
			break
	if c == len(lst1):
		ans = ans + 1
print(ans)


(n, k) = map(int, input().split())
digits = [str(i) for i in range(k + 1)]
count = 0
for i in range(n):
	num = input()
	good = True
	for j in range(k + 1):
		if digits[j] not in num:
			good = False
	if good:
		count += 1
print(count)


ret = -1
ss = '0123456789'
count1 = 0
count2 = 0
s = ''
(n, k) = input().split(' ')
n = int(n)
k = int(k)
while n > 0:
	s = input()
	for i in range(k + 1):
		ret = s.find(ss[i])
		if ret != -1:
			count1 += 1
			ret = -1
	if count1 >= k + 1:
		count2 += 1
	count1 = 0
	n -= 1
print(count2)


(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
listk = [j for j in range(0, k + 1)]
ans = 0
for i in range(n):
	a = int(input())
	b = str(a)
	list1 = list(b)
	list2 = [int(i) for i in list1]
	flag = True
	for j in listk:
		if j not in list2:
			flag = False
	if flag:
		ans += 1
print(ans)


(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 os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def connected_components(n, graph):
	(components, visited) = ([], [False] * n)

	def dfs(start):
		(component, stack) = ([], [start])
		while stack:
			start = stack[-1]
			if visited[start]:
				stack.pop()
				continue
			else:
				visited[start] = True
				component.append(start)
			for i in graph[start]:
				if not visited[i]:
					stack.append(i)
		return component
	for i in range(n):
		if not visited[i]:
			components.append(dfs(i))
	return components
for _ in range(int(input()) if not True else 1):
	(n, k) = map(int, input().split())
	ans = 0
	for i in range(n):
		s = input()
		st = set()
		for i in s:
			if int(i) < k + 1:
				st.add(int(i))
		ans += 1 if len(st) == k + 1 else 0
	print(ans)


from functools import reduce
from operator import *
from math import *
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)
(n, k) = map(int, input().split())
ans = 0
for i in range(n):
	cnt = [0] * 10
	a = int(input())
	while a:
		cnt[a % 10] += 1
		a //= 10
	if all((cnt[i] for i in range(k + 1))):
		ans += 1
print(ans)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(str(input()))
x = 0
for i in range(n):
	t = True
	for j in range(k + 1):
		if str(j) not in a[i]:
			t = False
	if t:
		x += 1
print(x)


(a, n) = input().split()
a = int(a)
n = int(n)
s = 0
l = []
for i in range(n + 1):
	l.append(i)
for i in range(a):
	f = 0
	st = input()
	for j in l:
		k = str(j)
		if k not in st:
			f = 1
	if f == 0:
		s += 1
print(s)


(n, k) = map(int, input().split())
ans = 0
for _ in range(n):
	x = input()
	good = True
	for i in range(k + 1):
		if str(i) not in x:
			good = False
			break
	if good:
		ans += 1
print(ans)


s = input().split(' ')
n = int(s[0])
k = int(s[1])
good = 0
for i in range(n):
	nbr = input()
	j = 0
	while j <= k and str(j) in nbr:
		j += 1
	if j > k:
		good += 1
print(good)


(n, k) = map(int, input().split())
r = 0
for i in range(n):
	t = input()
	visited = [False] * (k + 1)
	for i in t:
		if int(i) > k:
			continue
		else:
			visited[int(i)] = True
	if True in visited:
		if visited.count(True) == k + 1:
			r = r + 1
print(r)


(n, k) = 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)


(n, k) = [int(x) for x in input().split()]
s = 0
goodset = set([str(x) for x in range(k + 1)])
for i in range(n):
	num = input()
	if goodset.issubset(set(num)):
		s += 1
print(s)


a = 0
s = 0
lst = []
(z, x) = [int(c) for c in input().split()]
for v in range(z):
	b = [int(p) for p in input()]
	lst.append(b)
for n in lst:
	for m in range(x + 1):
		if m in n:
			a = a + 1
	if a == x + 1:
		s += 1
	a = 0
print(s)


(n, k) = map(int, input().split())
out = 0
k_good = [x for x in range(k + 1)]
good = []
for i in range(n):
	a = int(input())
	(length, count) = (len(str(a)), 0)
	lis = k_good.copy()
	if length > k:
		if a in good:
			out += 1
		else:
			for i in range(length):
				dig = a % 10
				a //= 10
				if dig in lis:
					count += 1
					lis.remove(dig)
			if count == k + 1:
				out += 1
				good.append(a)
print(out)


(n, k) = map(int, input().split())
cnt = 0
for i in range(n):
	s = str(input())
	for j in range(k + 1):
		if chr(j + 48) not in s:
			break
	else:
		cnt += 1
print(cnt)


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


def is_good(s, k):
	digits = [0] * (k + 1)
	for c in s:
		d = int(c)
		if d <= k:
			digits[d] = 1
	return sum(digits) == k + 1
(n, k) = [int(s) for s in input().split()]
ans = 0
for _ in range(n):
	s = input()
	if is_good(s, k):
		ans += 1
print(ans)


def solve(n, k, a):
	count = 0
	for num in a:
		notCorrect = False
		for i in range(0, k + 1):
			if str(i) not in num:
				notCorrect = True
				break
		if not notCorrect:
			count += 1
	return count
(n, k) = map(int, input().split(' '))
_n = 0
a = list()
while _n < n:
	a.append(input())
	_n += 1
print(solve(n, k, a))


def solve():
	count = 0
	(n, k) = map(int, input().split())
	for _ in range(n):
		set_nums = set(input())
		good = True
		for i in range(k + 1):
			if str(i) not in set_nums:
				good = False
		if good:
			count += 1
	print(count)
solve()


(n, k) = map(int, input().split())
cnt = 0
for i in range(n):
	num = input()
	good = True
	for i in range(k + 1):
		if not str(i) in num:
			good = False
			break
	cnt += good
print(cnt)


(n, k) = map(int, input().split())
check = set(map(str, range(k + 1)))
cnt = 0
while n != 0:
	s = input()
	if check.issubset(s):
		cnt += 1
	n -= 1
print(cnt)


from collections import Counter

def sol(xs, k):
	test = ''.join(map(str, range(k + 1)))
	c = 0
	for x in xs:
		x = ''.join([key for (key, val) in Counter(sorted(x)).items()])
		if test in x:
			c += 1
	print(c)
(n, k) = list(map(int, input().strip().split()))
xs = [input().strip() for _ in range(n)]
sol(xs, k)


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


(n, k) = [int(x) for x in input().split()]
numbers = dict()
total_count = 0
for i in range(n):
	count = 0
	is_good = True
	for i in range(k + 1):
		numbers[i] = 0
	num = int(input())
	while num != 0:
		new_num = int(num % 10)
		if numbers.get(new_num, '') != '':
			if numbers.get(new_num) == 0:
				count += 1
				numbers[new_num] = 1
		num = int(num / 10)
	if count == k + 1:
		total_count += 1
print(total_count)


(n, k) = map(int, input().split())
shit = 0
lists = []
newton = 0
for i in range(n):
	digits = input()
	for i in digits:
		lists.append(int(i))
		thelist = list(set(lists))
	newton = 0
	for t in range(0, k + 1):
		if t in thelist:
			newton += 1
		if newton == k + 1:
			shit += 1
	lists.clear()
print(shit)


(n, k) = map(int, input().split())
count = 0
for _ in range(n):
	s = list(map(int, input()))
	for i in range(k + 1):
		if i not in s:
			break
	else:
		count += 1
print(count)


string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
k = 0
for x in range(a):
	n = input()
	for y in range(b + 1):
		if not str(y) in n:
			break
	else:
		k += 1
print(k)


def main():
	(n, k) = list(map(int, input().split()))
	ans = 0
	for _ in range(n):
		num = input()
		d = set()
		for i in num:
			x = int(i)
			if x <= k:
				d.add(x)
		if len(d) == k + 1:
			ans += 1
	print(ans)
main()


temp = input().split(' ')
n = int(temp[0])
k = int(temp[1])
output = 0
for i in range(n):
	t = input()
	for j in range(k + 1):
		if t.count(str(j)) == 0:
			output -= 1
			break
	output += 1
print(output)


def main():
	(n, k) = map(int, input().split())
	k += 1
	tot = 0
	for _ in range(n):
		l = [False] * 10
		for c in input():
			l[ord(c) - 48] = True
		if all(l[:k]):
			tot += 1
	print(tot)
main()


(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))


def main():
	(n, k) = map(int, input().split())
	cnt = 0
	for _ in range(n):
		temp = 0
		number = str(input())
		num = list(number)
		num.sort()
		for x in num:
			if int(x) == temp:
				temp += 1
		if k <= temp - 1:
			cnt += 1
	print(cnt)
main()


(n, k) = input().split(' ')
a = 0
for i in range(int(n)):
	l = [0] * (int(k) + 1)
	s = list(input())
	for j in s:
		if int(j) <= int(k):
			l[int(j)] = 1
	if l.count(0) == 0:
		a += 1
print(a)


(n, t) = [int(n) for n in input().split()]
f = 2
c = 0
for i in range(n):
	x = int(input())
	l = str(x)
	for j in range(t + 1):
		if str(j) in l:
			f = 0
			continue
		else:
			f = 1
			break
	if f != 1:
		c += 1
print(c)


ins = input().split()
(n, k) = (int(ins[0]), int(ins[1]))
l = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
ans = 0
for i in range(n):
	x = input()
	s = set(x)
	if set(l[:k + 1]) <= s:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
numbers = []
for i in range(0, n):
	numbers.append(input())
good = 0
for number in numbers:
	kgood = 0
	for i in range(0, k + 1):
		if str(i) in str(number):
			kgood += 1
	if kgood == k + 1:
		good += 1
print(good)


(n, k) = map(int, input().split())
a = 0
b = [str(i) for i in range(k + 1)]
for i in range(n):
	nn = input()
	for j in b:
		if j not in nn:
			a += 1
			break
print(n - a)


l = list(map(int, input().split()))
n = l[0]
k = l[1]
count1 = 0
count2 = 0
chk = -1
s = '0123456789'
for i in range(n):
	a = input()
	for j in range(k + 1):
		chk = a.find(s[j])
		if chk != -1:
			count1 += 1
			chk = -1
	if count1 >= k + 1:
		count2 += 1
	count1 = 0
print(count2)


n_and_k = input().split()
n = int(n_and_k[0])
k = int(n_and_k[1])
result = list()
i = 0
while i < n:
	number = input()
	x = 0
	for j in range(0, k + 1):
		if str(j) in number:
			x += 1
			if k + 1 == x:
				result.append(number)
				x = 0
				continue
		else:
			break
	i += 1
print(len(result))


(a, b) = map(int, input().split())
ans = 0
for i in range(a):
	cnt = 0
	l = input()
	l = set(l)
	l = list(l)
	for i in range(len(l)):
		if int(l[i]) <= b:
			cnt += 1
	if cnt == b + 1:
		ans += 1
print(ans)


kn = list(map(int, input().split()))
numGood = 0

def kgood(k, a):
	for i in range(k + 1):
		if not i in a:
			return False
	return True
for i in range(kn[0]):
	inp = list(map(int, list(input())))
	if kgood(kn[1], inp):
		numGood += 1
print(numGood)


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)


(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)


(n, k) = [int(x) for x in input().split()]
c = 0
for i in range(n):
	l = [int(x) for x in list(str(input()))]
	d = dict()
	for i in l:
		if i in d.keys():
			d[i] += 1
		else:
			d[i] = 1
	j = list(d.keys())
	nt = True
	for i in range(k + 1):
		if not i in j:
			nt = False
	if nt:
		c += 1
print(c)


def IsGoodNumber(k, number):
	strNum = str(number)
	for i in range(k + 1):
		if str(i) not in strNum:
			return False
	return True
(n, k) = map(int, input().split())
goodNum = 0
for y in range(n):
	if IsGoodNumber(k, int(input())):
		goodNum += 1
print(goodNum)


(y, x) = [int(x) for x in input().split()]
z = 0
l = x
f = 0
while y != 0:
	ay = input()
	while str(x) in ay and x >= 0:
		z += 1
		x = x - 1
	z -= 1
	x = l
	if z == l:
		f += 1
	y -= 1
	z = 0
print(f)


(n, k) = map(int, input().split())
d = {}
arr = []
total = 0
for i in range(n):
	arr.append(int(input()))
for i in range(n):
	val = arr[i]
	if val in d:
		total += d[val]
	else:
		d1 = {}
		while val:
			v = val % 10
			if v <= k and v not in d1:
				d1[v] = 1
			val = int(val / 10)
		if len(d1.keys()) == k + 1:
			d[arr[i]] = 1
			total += 1
		else:
			d[arr[i]] = 0
print(total)


(a, b) = map(int, input().split())
b += 1
d = [i for i in range(b)]
z = 0
for i in range(a):
	c = input()
	x = [int(i) for i in c]
	x = set(x)
	x = [i for i in x]
	x = sorted(x)
	if len(x) >= b:
		x = x[:b]
		if x == d:
			z += 1
print(z)


(n, k) = input().split()
n = int(n)
f = 0
k = int(k)
count = 0
for i in range(n):
	a = input()
	for j in range(k + 1):
		if str(j) not in a:
			f = 1
			break
	if f == 0:
		count += 1
	else:
		pass
	f = 0
print(count)


__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) = (int(i) for i in input().split())
c = 0
for i in range(n):
	s = input()
	for j in range(k + 1):
		if str(j) not in s:
			c += 1
			break
print(n - c)


(lst_num, num) = map(int, input().split())
a_list = list(range(0, num + 1))
all_list = []
for n in range(lst_num):
	lst = str(input())
	lst = [int(x) for x in str(lst)]
	sorted_lst = sorted(lst)
	sorted_lst = list(dict.fromkeys(sorted_lst))
	all_list.append(sorted_lst)
count = 0
for each in all_list:
	counter = 0
	for item in a_list:
		if item in each:
			counter += 1
	if counter == len(a_list):
		count += 1
print(count)


(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)


(n, k) = map(int, input().split())
count = 0
for i in range(n):
	lst = [0] * (k + 1)
	s = input()
	for j in s:
		if int(j) <= k:
			lst[int(j)] = 1
	if 0 not in lst:
		count += 1
print(count)


x = input()
x = x.split()
o = int(x[0])
y = int(x[1])
k = 0
w = '0123456789'
m = w[:y + 1]
for x in range(o):
	d = input()
	p = True
	for i in m:
		if i not in d:
			p = False
	if p == True:
		k = k + 1
print(k)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
count = 0
for i in range(n):
	s = input()
	flag = 0
	for i in range(k + 1):
		if str(i) not in s:
			flag = 1
			break
	if flag == 0:
		count += 1
print(count)


(n, k) = map(int, input().split())
c = 0
for i in range(n):
	s = list(input())
	y = True
	for j in range(k + 1):
		if str(j) not in s:
			y = False
			break
	if y:
		c += 1
print(c)


(n, k) = map(int, input().split())
res = 0
for i in range(n):
	inp = input()
	ss = 0
	for i in range(k + 1):
		if inp.count(str(i)) > 0:
			ss += 1
	if ss >= k + 1:
		res += 1
print(res)


(n, k) = map(int, input().split(' '))
ct = 0
for i in range(n):
	s = int(input())
	L = [0] * 11
	while s > 0:
		L[s % 10] += 1
		s //= 10
	used = True
	for j in range(k + 1):
		if L[j] == 0:
			used = False
	if used:
		ct += 1
print(ct)


(n, k) = list(map(int, input().split()))
t2 = range(0, k + 1)
res = 0
for _ in range(n):
	s = input()
	accept = True
	for i in t2:
		if str(i) not in s:
			accept = False
			break
	if accept:
		res += 1
print(res)


def good_number(k, arr):
	count = 0
	for num in arr:
		flag = True
		for i in range(k + 1):
			if str(i) not in str(num):
				flag = False
				break
			else:
				continue
		if flag:
			count += 1
	return count
[n, k] = list(map(lambda x: int(x), input().split(' ')))
arr = []
for i in range(n):
	num = int(input())
	arr.append(num)
response = good_number(k, arr)
print(response)


(n, k) = map(int, input().split())
b = set()
m = 0
for i in range(k + 1):
	b.add(str(i))
for i in range(n):
	s = set(input())
	if s >= b:
		m += 1
print(m)


(n, k) = map(int, input().split())
p = 0
for i in range(n):
	t = input()
	u = 0
	for j in range(k + 1):
		if str(j) not in t:
			u += 1
			break
	if u == 0:
		p += 1
print(p)


(n, k) = list(map(int, input().split()))
ans = 0
for i in range(n):
	stop = False
	cur = []
	a = input()
	for j in a:
		cur.append(j)
	for j in range(0, k + 1):
		if str(j) not in cur:
			stop = True
			break
	if stop:
		continue
	else:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
sum = 0
for i in range(n):
	x = input()
	for j in range(k + 1):
		if str(j) not in x:
			break
	else:
		sum += 1
print(sum)


(n, k) = [int(x) for x in input().split()]
k = list(range(k + 1))
b = 0
for x in range(n):
	line = input()
	line = [int(r) for r in list(line)]
	for j in k:
		if j not in line:
			break
	else:
		b += 1
print(b)


(n, k) = input().split()
n = int(n)
k = int(k)
c = 0
for i in range(n):
	a = input()
	flag = True
	for j in range(k + 1):
		if str(j) not in a:
			flag = False
	if flag:
		c += 1
print(c)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
(n, k) = value()
ans = 0
while n > 0:
	s = input()
	n -= 1
	digits = set()
	for i in s:
		if int(i) <= k:
			digits.add(i)
	if len(digits) == k + 1:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
count = 0
for _ in range(n):
	a = [0 for i in range(10)]
	m = int(input())
	while m > 0:
		a[m % 10] = 1
		m = m // 10
	for j in range(10):
		if j <= k and a[j] == 0:
			break
	else:
		count += 1
print(count)


(n, k) = tuple(map(int, input().split()))
counter = 0
k_number = {str(number) for number in range(k + 1)}
for i in range(n):
	entry = set(input())
	if entry.intersection(k_number) == k_number:
		counter += 1
print(counter)


(n, m) = map(int, input().split())
c1 = 0
c = 0
r = -1
ss = '0123456789'
while n > 0:
	s = input()
	for i in range(m + 1):
		r = s.find(ss[i])
		if r != -1:
			c = c + 1
			r = -1
	if c >= m + 1:
		c1 = c1 + 1
	c = 0
	n = n - 1
print(c1)


(a, b) = map(int, input().split())
j = 0
c = []
for i in range(b + 1):
	c.append(str(i))
for i in range(a):
	a = set(str(int(input())))
	if set(c).intersection(a) == set(c):
		j += 1
print(j)


def is_good(num, k):
	g = [False] * 10
	while num > 0:
		d = num % 10
		g[d] = True
		num //= 10
	good = True
	for i in range(k + 1):
		if not g[i]:
			good = False
			break
	return good
(n, k) = [int(x) for x in input().split()]
count = 0
for i in range(n):
	ai = int(input())
	if is_good(ai, k):
		count += 1
print(count)


(n, m) = input().split()
n = int(n)
m = int(m)
contador = 0
for x in range(n):
	dato = input()
	dato = sorted(set(dato))
	if m < len(dato):
		if m == int(dato[m]):
			contador = contador + 1
print(contador)


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)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
(n, k) = L()
A = [list(set(list(input()))) for i in range(n)]
cnt = 0
for ele in A:
	x1 = []
	for x in ele:
		if int(x) <= k:
			x1.append(x)
	if x1 and max(x1) == str(k) and (len(x1) == k + 1):
		cnt += 1
print(cnt)
endtime = time.time()


(n, k) = input().split()
n = int(n)
k = int(k)
count = 0
c = 0
for i in range(n):
	f = False
	x = input()
	j = 0
	while j <= k and str(j) in x:
		j += 1
		f = True
	if f and j > k:
		count += 1
print(count)


import sys
input = sys.stdin.readline
import math

def inpit():
	return int(input())

def inplt():
	return list(map(str, input().split()))

def inpstr():
	s = input()
	return list(s[:len(s) - 1])

def inpspit():
	return map(int, input().split())
import math
pow = math.pow
fl = math.floor
ceil = math.ceil
dis = math.hypot

def lcm(a):
	return abs(math.prod(a)) // math.gcd(*a)
(n, k) = inpspit()
lt = []
for i in range(0, k + 1):
	lt.append(str(i))
s = set(lt)
c = 0
for i in range(n):
	a = set(list(input()))
	if len(s) == len(a.intersection(s)):
		c = c + 1
print(c)


(n, k) = map(int, input().split())
cnt = 0
for i in range(n):
	x = input()
	if all((str(i) in x for i in range(0, k + 1))):
		cnt += 1
	else:
		cnt += 0
print(cnt)


(n, k) = map(int, input().split())
count = 0
for _ in range(n):
	arr = input()
	d = {str(i): 0 for i in range(k + 1)}
	for i in arr:
		if i in d:
			d[i] = 1
	if sum(d.values()) == k + 1:
		count += 1
print(count)


(n, k) = map(int, input().split())
z = c = 0
for i in range(n):
	s = input()
	for j in range(k + 1):
		if str(j) in s:
			z += 1
		else:
			break
	if z == k + 1:
		c += 1
	z = 0
print(c)


(n, k) = input().split()
n = int(n)
k = int(k)
count = 0
c = 0
for i in range(n):
	x = input()
	if all((str(i) in x for i in range(0, k + 1))):
		count += 1
	else:
		count += 0
print(count)


(n, k) = map(int, input().split())
s = set(map(str, range(k + 1)))
coun = 0
for i in range(n):
	s1 = set(str(input()))
	if s - s1 == set():
		coun = coun + 1
print(coun)


import math
(n, k) = input().split()
k = int(k)
cont = 0
arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for x in range(int(n)):
	number = input()
	i = len(number)
	all = True
	for y in range(i):
		arr[int(number[y])] = 1
	for y in range(10):
		if k >= y:
			if arr[y] == 0:
				all = False
				break
		else:
			break
	if all:
		cont = cont + 1
	for y in range(10):
		arr[y] = 0
print(str(cont) + ' ')


import math

def isk(n, d, k):
	for i in n:
		if i in d:
			d[i] = 1
	for i in range(k + 1):
		if str(i) in d and d[str(i)] == 0:
			return False
	return True
(n, k) = map(int, input().split())
d = {}
c = 0
for _ in range(n):
	s = input()
	for i in range(k + 1):
		d[str(i)] = 0
	if isk(s, d, k):
		c += 1
print(c)


inputting = input().split(' ')
n = inputting[0]
k = inputting[1]
good = [i for i in range(int(k) + 1)]
counter = 0
for i in range(int(n)):
	array = list(set([int(i) for i in input()]))
	array.sort()
	if good == array[0:len(good)]:
		counter += 1
print(counter)


(n, k) = map(int, input().split())
a = 0
for i in range(n):
	s = input()
	s = sorted(s)
	c = 0
	for j in s:
		x = ord(j) - ord('0')
		if x == c and x <= k:
			c += 1
	if c == k + 1:
		a += 1
print(a)


(x, y) = map(int, input().split())
c = set(range(y + 1))
r = 0
for i in range(x):
	a = set(map(int, input()))
	if a & c == c:
		r += 1
print(r)


(n, k) = map(int, input().split())
nums = []
for i in range(n):
	nums.append(input())
counter = n
k = range(0, k + 1)
for item in nums:
	for c in k:
		if str(c) not in item:
			counter -= 1
			break
print(counter)


(n, k) = map(int, input().split())
a = []
b = []
c = 0
for i in range(0, k + 1):
	a.append(i)
for i in range(n):
	x = list(set(map(int, input())))
	b.append(x)
for i in b:
	x = 0
	for j in i:
		if j in a:
			x += 1
	if x == len(a):
		c += 1
	else:
		continue
print(c)


(n, p) = map(int, input().split())
ans = 0
for _ in range(n):
	a = input()
	for i in range(p + 1):
		if a.find(chr(i + ord('0'))) == -1:
			break
	else:
		ans += 1
print(ans)


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


(a, k) = input().split()
counter = int(a)
for i in range(int(a)):
	q = input()
	for j in range(int(k) + 1):
		if str(j) not in q:
			counter -= 1
			break
print(counter)


(N, K) = [int(x) for x in input().split()]
DigitsToCheck = {int(x) for x in range(K + 1)}
GoodNums = 0
for i in range(N):
	Nums = {int(ii) for ii in input()}
	if all((x in Nums for x in DigitsToCheck)):
		GoodNums += 1
print(GoodNums)


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

def check(list):
	for i in range(0, k + 1):
		if list[i] == 0:
			return False
	return True
for i in range(n):
	s = input()
	flag = True
	listt = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for d in s:
		listt[int(d)] = 1
	if check(listt):
		cnt += 1
print(cnt)


(n, k) = map(int, input().split())
sol = 0
k_digits = [str(i) for i in range(k + 1)]
for i in range(n):
	x = input()
	if all((i in x for i in k_digits)):
		sol += 1
print(sol)


(n, k) = [int(x) for x in input().split()]
l2 = []
co = 0
for i in range(n):
	s = list(input())
	ss = set(s)
	ss1 = list(ss)
	ss1.sort()
	fl = False
	for o in range(k + 1):
		if str(o) not in ss1:
			fl = True
			break
	if fl == True:
		pass
	else:
		co += 1
print(co)


from collections import Counter
(n, k) = map(int, input().split())
ans = 0
for _ in range(n):
	c = Counter(input())
	all_digit = True
	for i in range(0, k + 1):
		if c[str(i)] == 0:
			all_digit = False
	if all_digit:
		ans += 1
print(ans)


(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) = map(int, input().split())
ans = 0
for i in range(n):
	(x,) = map(int, input().split())
	s = set()
	while x:
		p = x % 10
		x //= 10
		if p <= k:
			s.add(p)
	if len(s) == k + 1:
		ans += 1
print(ans)


import sys
from decimal import *

def k_good(num_cad, k, digitos):
	cont_digitos = 0
	for dig in digitos:
		if dig in num_cad:
			cont_digitos += 1
	return cont_digitos == k + 1
(n, k) = [int(i) for i in sys.stdin.readline().split()]
digitos = [chr(i + ord('0')) for i in range(k + 1)]
cont = 0
for i in range(n):
	num_cad = sys.stdin.readline().strip()
	if k_good(num_cad, k, digitos):
		cont += 1
print(cont)


(n, k) = map(int, input().split())
num = {str(i) for i in range(k + 1)}
result = 0
for i in range(n):
	if len(set(input()) & num) == k + 1:
		result += 1
print(result)


(testCases, a) = map(int, input().split())
good = 0
lol = a + 1
for testCase in range(testCases):
	testing = [0] * lol
	n = input()
	d = set(list(n))
	for i in d:
		if int(i) < lol:
			testing[int(i)] += 1
	if 0 not in testing:
		good += 1
print(good)


X = list(map(int, input().split()))
Count = 0
for i in range(X[0]):
	Number = input()
	Check = True
	for j in range(X[1] + 1):
		if str(j) not in Number:
			Check = False
			break
	Count += 1 if Check else 0
print(Count)


import sys
x = input().split()
n = int(x[0])
k = int(x[1])
list = []
for i in range(0, n):
	y = input()
	list.append(y)
l = 0
for j in list:
	flag = 1
	for z in range(0, k + 1):
		if str(z) not in j:
			flag = 0
			break
	if flag == 1:
		l = l + 1
print(l)


(n, k) = [int(x) for x in input().split()]
res = 0
for i in range(n):
	m = input()
	s = set([])
	for j in m:
		if j <= str(k):
			s.add(j)
	if len(s) == k + 1:
		res += 1
print(res)


(n, k) = [int(x) for x in input().split()]
ans = 0
for i in range(n):
	s = sorted(input())
	for c in [str(x) for x in range(k + 1)]:
		if not s.count(c):
			break
	else:
		ans += 1
print(ans)


def good(s, k):
	for i in range(int(k) + 1):
		if str(i) not in s:
			return False
	return True
res = 0
(n, k) = input().split()
for _ in range(int(n)):
	if good(input(), k):
		res += 1
print(res)


import sys
(_, k) = map(int, input().strip().split())
count = 0
lines = sys.stdin.readlines()
for line in lines:
	line = line.strip()
	if not line:
		break
	s = sorted(list(set(map(int, line))))
	if len(s) >= k + 1 and s[k] == k:
		count += 1
print(count)


tot = 0

def ok(x):
	for t in [i for i in range(b + 1)]:
		if str(t) not in str(x):
			return False
	return True
(a, b) = map(int, input().split(' '))
for i in range(a):
	if ok(int(input())):
		tot += 1
print(tot)


(n, k) = input().split()
n = int(n)
k = int(k)
ans = 0
cond = True
for i in range(0, n):
	cond = True
	s = input()
	for j in range(0, k + 1):
		if s.count(str(j)) == 0:
			cond = False
	if cond:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
c = set(range(k + 1))
cnt = 0
for i in range(n):
	s = set(list(map(int, list(input()))))
	if s & c == c:
		cnt += 1
print(cnt)


(n, k) = [int(j) for j in input().split()]
count = 0
for j in range(n):
	s = str(input())
	ref = (k + 1) * [0]
	for a in range(len(s)):
		index = ord(s[a]) - 48
		if index <= k:
			ref[index] = 1
	if sum(ref) == k + 1:
		count += 1
print(count)


(n, k) = map(int, input().split())
ans = 0
for _ in range(n):
	x = input()
	ok = 1
	x = list(x)
	x.sort()
	cnt = 0
	for i in x:
		if int(i) == cnt + int('0'):
			cnt += 1
	if cnt > k:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
cnt = 0
for i in range(n):
	c = 0
	a = int(input())
	a = str(a)
	for j in range(k + 1):
		if str(j) in a:
			pass
		else:
			c = 1
	if c == 0:
		cnt += 1
print(cnt)


(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) = [int(x) for x in input('').split()]
ans = 0
for i in range(n):
	chk = [0] * 10
	good = True
	a = int(input(''))
	while a > 0:
		chk[a % 10] = 1
		a //= 10
	j = 0
	while j <= k:
		if chk[j] == 0:
			break
		j += 1
	if j == k + 1:
		ans += 1
print(ans)


from collections import Counter

def sol(xs, k):
	c = 0
	test = set(map(str, range(k + 1)))
	for x in xs:
		if test <= set(list(x)):
			c += 1
	print(c)
(n, k) = list(map(int, input().strip().split()))
xs = [input().strip() for _ in range(n)]
sol(xs, k)


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)


def k_number(lst, k):
	z = list()
	for elem in lst:
		elem1 = list(elem)
		elem2 = [int(i) for i in elem1]
		if set(elem2) & set(range(k + 1)) == set(range(k + 1)):
			z.append(elem)
	return len(z)
(m, n) = [int(i) for i in input().split()]
a = list()
for j in range(m):
	s = input()
	a.append(s)
print(k_number(a, n))


myMap = map(int, input().split())
myMap = list(myMap)
(n, r) = (myMap[0], myMap[1])
tempList = []
counter = 0
counter2 = 0
mainList = []
for i in range(n):
	mainList.append(input())
for i in range(n):
	for j in range(r + 1):
		tempList.append(j)
	num = mainList[i]
	for k in num:
		if int(k) in tempList:
			tempList.remove(int(k))
			if len(tempList) == 0:
				break
		else:
			continue
	if len(tempList) == 0:
		counter2 += 1
		tempList.clear()
	else:
		tempList.clear()
		continue
print(counter2)


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))))


from collections import Counter
(n, k) = [int(i) for i in input().split()]
c = 0
x = (k + 1) * k // 2
for i in range(n):
	s = []
	a = input()
	s += [int(i) for i in a if int(i) <= k]
	count = Counter(set(s))
	if sum(count.values()) >= k + 1 and len(set(s)) >= k + 1:
		c += 1
print(c)


(n, k) = list(map(int, input().split(' ')))
good_numbers = 0
for _ in range(n):
	is_good_number = True
	arr = list(map(int, list(input())))
	if k == 0:
		if 0 not in arr:
			is_good_number = False
	else:
		for i in range(k + 1):
			if i not in arr:
				is_good_number = False
				break
	if is_good_number:
		good_numbers += 1
print(good_numbers)


(n, k) = [int(x) for x in input().split()]
res = 0
d = {}
for i in range(n):
	a = input()
	try:
		if d[a]:
			res += 1
	except:
		c = 0
		d1 = {}
		for i in a:
			if int(i) <= k:
				try:
					if d1[i]:
						pass
				except:
					d1[i] = 1
					c += 1
			if c == k + 1:
				break
		if c == k + 1:
			res += 1
			d[a] = 1
print(res)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
l1 = list(set(l))
s = 0
for i in l1:
	c = 0
	for j in range(k + 1):
		if i.count(str(j)) == 0:
			c = 1
			break
	if not c:
		s += l.count(i)
print(s)


(n, k) = [int(i) for i in input().split()]
count = 0
k = ''.join([str(i) for i in range(k + 1)])
for _ in range(n):
	num = input()
	for i in k:
		if i not in num:
			break
	else:
		count += 1
print(count)


sum = 0
(n, k) = map(int, input().split())
for i in range(n):
	tt = int(input())
	s = set()
	while tt:
		m = tt % 10
		if m <= k:
			s.add(m)
		tt = int(tt / 10)
	if len(s) == k + 1:
		sum += 1
print(sum)


(n, k) = map(int, input().split())
ans = 0
for j in range(n):
	s = input()
	l = []
	for i in range(len(s)):
		if int(s[i]) <= k and int(s[i]) not in l:
			l.append(int(s[i]))
	if len(l) == k + 1:
		ans += 1
print(ans)


text = input()
n = int(text.split(' ')[0])
k = int(text.split(' ')[1])
count = 0
x = []
for i in range(0, k + 1):
	x.append(i)
for i in range(0, n):
	text2 = input()
	c = 0
	for b in x:
		if text2.count(str(b)) > 0:
			c += 1
	if c == k + 1:
		count += 1
print(count)


(n, m) = [int(i) for i in input().split()]
e = 0
for i in range(n):
	s = str(input())
	flag = 0
	for j in range(0, m + 1):
		if str(j) in s:
			pass
		else:
			flag = 1
	if flag == 0:
		e = e + 1
print(e)


(n, k) = map(int, input().split())
store = [str(x) for x in range(0, k + 1)]
cnt = 0
for _ in range(n):
	s = input().strip()
	ss = set()
	for x in s:
		ss.add(x)
	found = True
	for x in store:
		if x not in ss:
			found = False
			break
	if found:
		cnt += 1
print(cnt)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, k) = I()
ans = 0
for _ in range(n):
	a = [0] * 10
	for i in input():
		a[int(i)] = 1
	ans += sum(a[:k + 1]) == k + 1
print(ans)


(n, k) = map(int, input().split())
a = []
for i in range(0, 10):
	a.append(-2)
(r, z) = (0, 0)
for m in range(0, n):
	x = int(input())
	p = 0
	for j in range(0, 10):
		a[j] = -1
	while x != 0:
		p = x % 10
		a[p] = p
		x = x // 10
	for j in range(0, k + 1):
		if a[j] == -1:
			break
		else:
			r += 1
	if r == k + 1:
		z += 1
		r = 0
	else:
		r = 0
print(z)


(n, k) = input().split()
n = int(n)
k = int(k)
goodnum = 0
for i in range(n):
	k2 = input()
	flag = True
	for j in range(k + 1):
		if str(j) not in k2:
			flag = False
	if flag:
		goodnum += 1
print(goodnum)


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)


(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())
res = 0
while n > 0:
	s = input()
	s = sorted(s)
	c = 0
	for i in s:
		x = ord(i) - ord('0')
		if x == c and x <= k:
			c += 1
	if c == k + 1:
		res += 1
	n -= 1
print(res)


(n, k) = list(map(int, input().split()))
c = 0
kk = set(map(str, range(k + 1)))
for x in range(n):
	z = set(input())
	if kk.issubset(z):
		c += 1
print(c)


(n, k) = list(map(int, input().split()))
s = ''.join([str(i) for i in range(k + 1)])
res = 0
for _ in range(n):
	x = list(input())
	x = set(x)
	x = list(x)
	x.sort()
	x = ''.join(x)
	if x[:k + 1] == s:
		res += 1
print(res)


(n, k) = [int(i) for i in input().split()]
num = []
gud = 0
flag = True
for k in range(0, k + 1):
	num.append(str(k))
for i in range(n):
	a = str(input())
	flag = True
	for n in num:
		if n not in a:
			flag = False
	if flag == True:
		gud += 1
print(gud)


(n, k) = map(int, input().split())
r = list(range(0, k + 1))
c = 0
for _ in range(n):
	x = input()
	flag = True
	for i in r:
		if not str(i) in x:
			flag = False
			break
	c += 1 if flag else 0
print(c)


(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)


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
for _ in range(num):
	(n, k) = zz()
	cnt = 0
	for i in range(n):
		s = fast()
		c = 1
		for i in range(k + 1):
			if s.count(str(i)) == 0:
				c = 0
				break
		if c:
			cnt += 1
	print(cnt)


(n, k) = map(int, input().split())
ans = 0
for i in range(n):
	S = list(map(int, list(input())))
	S = list(set(S))
	S.sort()
	if S[0] == 0 and len(S) > k and (S[k] == k):
		ans += 1
print(ans)


def dildo():
	d = {}
	c = 0
	m = 0
	k = ''
	n = input()
	a = int(n.split()[1])
	n = int(n.split()[0])
	for i in range(a + 1):
		k += str(i)
	for i in range(n):
		x = input()
		for i in x:
			if i in k:
				if i not in d:
					d[i] = 1
		if len(list(d.items())) == a + 1:
			c += 1
		d = {}
	print(c)
dildo()


(n, k) = map(int, input().split())
(cnt, oup) = (0, 0)
for j in range(n):
	s = input()
	for i in range(k + 1):
		if str(i) in s:
			cnt += 1
	if cnt - 1 == k:
		oup += 1
	cnt = 0
print(oup)


from sys import stdin
stdin.readline

def mp():
	return map(int, input().split())

def it():
	return int(input())
count = 0
(n, k) = mp()
for _ in range(n):
	a = input()
	v = set()
	ans = 0
	for i in a:
		if int(i) <= k:
			v.add(i)
	if len(v) == k + 1:
		count += 1
print(count)


(x, y) = map(int, input().split())
counter = 0
for i in range(x):
	z = input()
	v = 0
	for j in range(y + 1):
		if str(j) in z:
			v += 1
	if v == y + 1:
		counter += 1
print(counter)


(n, k) = map(int, input().split())
l = 0
for i in range(n):
	a = input()
	for i in range(k + 1):
		if str(i) not in a:
			a = ''
			break
		if i == k and str(i) in a:
			l += 1
print(l)


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)


(n, k) = map(int, input().split())
count = 0
for i in range(n):
	ip = input()
	num = []
	for ch in ip:
		num.append(int(ch))
	for j in range(k + 1):
		if j not in num:
			count += 1
			break
print(n - count)


(x, y) = map(int, input().split())
z = 0
for i in range(x):
	li = []
	for i in range(y + 1):
		li.append(0)
	a = input()
	flag = 0
	for j in range(len(a)):
		if int(a[j]) <= y:
			li[int(a[j])] = 1
	for j in range(y + 1):
		if li[j] == 0:
			flag = 1
			break
	if flag == 0:
		z += 1
print(z)


(n, k) = map(int, input().split())
count = 0
while n:
	cnt = [0] * (k + 1)
	s = input()
	for i in range(len(s)):
		if int(s[i]) <= k:
			if cnt[int(s[i])] == 0:
				cnt[int(s[i])] += 1
	if sum(cnt) == k + 1:
		count += 1
	n -= 1
print(count)


(n, k) = map(int, input().split())
d = set(map(str, range(k + 1)))
print(sum((1 for _ in range(n) if d <= set(input()))))


(a, b) = map(int, input().split())
ans = 0
for _ in range(a):
	num = input()
	isGood = True
	for m in range(b + 1):
		if str(m) not in num:
			isGood = False
	if isGood:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
re = 0
for i in range(0, n):
	m = input()
	mset = sorted(set(m))
	if len(mset) > k and int(mset[k]) == k:
		re += 1
print(re)


(n, k) = map(int, input().split(' '))
for_check = [int(z) for z in range(k + 1)]
count = 0
for i in range(n):
	a = int(input())
	digits = [int(x) for x in str(a)]
	digits_set = list(set(digits))
	if set(for_check).issubset(digits_set):
		count = count + 1
print(count)


(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) = 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)


import sys
import math
input = sys.stdin.readline
st = '0123456789'
(n, k) = map(int, input().strip().split())
ans = 0
for _ in range(n):
	s = input().strip()
	ans += all((j in s for j in st[:k + 1]))
print(ans)


(n, k) = input().split()
n = int(n)
k = int(k)
count = 0
while n > 0:
	temp = int(input())
	val = {}
	for key in range(0, 11):
		val[key] = 0
	flag = 1
	while temp > 0:
		val[temp % 10] = 1
		temp = int(temp / 10)
	for key in range(0, k + 1):
		if val[key] != 1:
			flag = 0
			break
	if flag:
		count = count + 1
	n = n - 1
print(count)


l = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
(a, b) = [int(x) for x in input().split()]
ans = a
for _ in range(a):
	s = input()
	for i in l[:b + 1]:
		if i not in s:
			ans -= 1
			break
print(ans)


(x, y) = map(int, input().split())
sum = 0
for i in range(x):
	number1 = list(map(int, list(input())))
	number2 = list(range(y + 1))
	number1.sort()
	if set(number2).issubset(number1):
		sum += 1
print(sum)


(n, k) = map(int, input().split())
a = []
for _ in range(n):
	tmp = list(set(input()))
	tmp.sort()
	tmp = ''.join(tmp)
	a.append(tmp)
k = ''.join([str(i) for i in range(k + 1)])
ans = 0
for i in a:
	if k in i:
		ans += 1
print(ans)


c = list(map(int, input().split()))
n = c[0]
k = c[1]
cnt = 0
status = 1
for i in range(n):
	x = input()
	for j in range(k + 1):
		if str(j) not in x:
			status = 0
			break
		else:
			status = 1
	if status:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
s = set('0123456789'[:m + 1])
cn = 0
for i in range(n):
	a = set(input())
	if a >= s:
		cn += 1
print(cn)


def is_good(num, k):
	mask = [False] * (k + 1)
	cnt = k + 1
	while num != 0:
		if cnt == 0:
			return True
		dig = num % 10
		num = num // 10
		if dig <= k and (not mask[dig]):
			cnt -= 1
			mask[dig] = True
	return cnt == 0
(n, k) = map(int, input().split())
cnt = 0
for i in range(n):
	num = int(input())
	if is_good(num, k):
		cnt += 1
print(cnt)


import sys
import math

def mf(val, l):
	ll = len(val) - 1
	t = [0] * 10
	for i in val[:ll]:
		v = ord(i) - ord('0')
		t[v] += 1
	for i in range(l + 1):
		if t[i] == 0:
			return False
	return True
(n, k) = [int(x) for x in sys.stdin.readline().split()]
d = dict()
res = 0
for i in range(n):
	istr = sys.stdin.readline()
	if mf(istr, k) == True:
		if istr in d:
			res += 1
		else:
			d[istr] = 1
			res += 1
print(res)


(n, k) = map(int, input().split())
c = 0
for i in range(n):
	l = list(input())
	l = list(set(l))
	l.sort()
	m = l[:k + 1]
	if len(m) >= k + 1 and m[0] == '0' and (int(m[k]) == k):
		c += 1
print(c)


e = str(input())
e = e.split(' ')
n = int(e[0])
k = int(e[1])
m = [str(input()) for i in range(n)]
b = []
while k >= 0:
	b.append(str(k))
	k -= 1
i = 0
l = 0
c = 0
z = 0
for l in range(len(m)):
	for i in range(len(b)):
		if not str(b[i]) in str(m[l]):
			c += 1
	if c == 0:
		z += 1
	c = 0
print(z)


(n, k) = map(int, input().split())
a = [input() for i in range(n)]
ans = 0
for i in range(n):
	ok = True
	for j in range(k + 1):
		if str(j) not in a[i]:
			ok = False
			break
	if ok:
		ans += 1
print(ans)


def containsZero(arr):
	for i in arr:
		if i == 0:
			return True
	return False

def isGoodNumber(num):
	for i in list(str(num)):
		if int(i) <= k:
			arr[int(i)] += 1
	if not containsZero(arr):
		return True
	return False
(n, k) = [int(x) for x in input().split()]
res = 0
while n > 0:
	arr = [0] * (k + 1)
	num = int(input())
	if isGoodNumber(num):
		res += 1
	n -= 1
print(res)


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	gets = lambda : [str(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[n, k] = get()
	c = 0
	k = {str(i) for i in range(k + 1)}
	for z in range(n):
		[g] = gets()
		g = set(g)
		if k <= g:
			c += 1
	print(c)
	if mode == 'file':
		f.close()
main()


(n, k) = map(int, input().split())
s = 0
a = [0 for i in range(k + 1)]
for i in range(n):
	a = [0 for i in range(k + 1)]
	curr = input()
	for c in curr:
		if int(c) >= len(a):
			continue
		a[int(c)] = 1
	if 0 not in a:
		s += 1
print(s)


(n, k) = map(int, input().split())
ans = n
for i in range(n):
	number = input()
	for j in range(k + 1):
		if str(j) not in number:
			ans -= 1
			break
print(ans)


a = list(map(int, input().split()))
b = 0
c = set(map(str, range(a[1] + 1)))
for i in range(a[0]):
	d = input()
	if c - set(d) == set():
		b += 1
print(b)


import sys
(n, k) = map(int, sys.stdin.readline().split())
count = 0
for _ in range(n):
	a = input()
	s = set([int(_) for _ in a])
	good = True
	for n in range(k + 1):
		if n not in s:
			good = False
			break
	if good:
		count += 1
print(count)


(m, n) = map(int, input().split())
l1 = list(range(0, n + 1))
c = 0
for i in range(m):
	l = list((int(x) for x in input()))
	l = list(set(l))
	for j in l1:
		if j not in l:
			break
	else:
		c = c + 1
print(c)


(n, k) = map(int, input().split())
count1 = 0
for i in range(n):
	a = list(map(int, input()))
	a.sort()
	count = 0
	for j in set(a):
		if j <= k:
			count += 1
	if count == k + 1:
		count1 += 1
print(count1)


(n, k) = map(int, input().split())
f = list(range(0, k + 1))
s = ''
d = []
c = 0
a = n
for i in range(n):
	kj = input()
	for j in f:
		if str(j) not in kj:
			c += 1
			break
print(n - c)


(n, k) = map(int, input().split())
(temp, count) = (0, 0)
st = '0123456789'
while n:
	number = input()
	for i in range(k + 1):
		res = number.find(st[i])
		if res != -1:
			temp += 1
			res = -1
	if temp >= k + 1:
		count += 1
	temp = 0
	n -= 1
print(count)


def findKNum(nums, k):
	goodNumsCount = 0
	if k == 0:
		for num in nums:
			if '0' in str(num):
				goodNumsCount += 1
		return goodNumsCount
	listRange = list(range(int(k) + 1))
	tmp = list(range(int(k) + 1))
	for num in nums:
		for n in str(num):
			if int(n) in listRange:
				listRange.pop(listRange.index(int(n)))
		if len(listRange) == 0:
			goodNumsCount += 1
		listRange = list(range(int(k) + 1))
	return goodNumsCount
nums = input().split()
arr = []
for i in range(int(nums[0])):
	num = int(input())
	arr.append(int(num))
print(findKNum(arr, int(nums[1])))


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


(n, k) = [int(x) for x in input().split()]
count = 0
for i in range(n):
	s = str(input())
	flag = 0
	for j in range(0, k + 1):
		if str(j) not in s:
			flag = 1
			break
	if flag == 0:
		count += 1
print(count)


(n, k) = map(int, input().split())
ans = 0
se = set(range(k + 1))
for _ in range(n):
	s = set(map(int, input()))
	if s.intersection(se) == se:
		ans += 1
print(ans)


(numberCount, k) = list(map(int, input().split(' ')))

def arePresent(digits, k):
	if k == 0:
		return 0 in digits
	else:
		for i in range(k + 1):
			if not i in digits:
				return False
		return True
goodCount = 0
for i in range(numberCount):
	digits = list(map(int, input()))
	goodCount += 1 if arePresent(digits, k) else 0
print(goodCount)


(n, k) = map(int, input().split())
arr = [input() for i in range(n)]
c = 0
for i in arr:
	f = True
	for j in range(10):
		if j <= k and str(j) not in i:
			f = False
			break
	if f:
		c += 1
print(c)


(n, k) = map(int, input().split())
ans = 0
for i in range(n):
	num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	s = input()
	for q in s:
		num[int(q)] = 1
	if sum(num[0:k + 1]) == k + 1:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
a = [input() for _ in range(n)]
SAMPLE = '0123456789'
compare = set(list(SAMPLE[:k + 1]))
result = 0
for c in a:
	tmp = set(list(c))
	if compare.issubset(tmp):
		result += 1
print(result)


from sys import stdin, stdout
import sys
INF = 100000000000.0
import math

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
(n, k) = get_ints()
ans = 0
while n:
	n -= 1
	a = get_int()
	s = set()
	while a:
		if a % 10 <= k:
			s.add(a % 10)
		a = a // 10
	if len(s) == k + 1:
		ans += 1
print(ans)


(n, k) = [int(x) for x in input().split()]
s = set('0123456789'[:k + 1])
ans = 0
for _ in range(n):
	a = str(input())
	t = set(a)
	if len(t) < k + 1:
		continue
	if not s <= t:
		continue
	ans += 1
print(ans)


import math

def isgood(n, x):
	l = set()
	while n:
		t = n % 10
		if t <= x:
			l.add(t)
		n = int(n / 10)
	if len(l) > x:
		return 1
	return 0
(n, k) = input().split()
n = int(n)
k = int(k)
x = 0
while n:
	n -= 1
	t = int(input())
	if isgood(t, k):
		x += 1
print(x)


(n, k) = map(int, input().split())
k = list(range(k + 1))
count = 0
for i in range(n):
	a = input()
	a = [int(r) for r in list(a)]
	for item in k:
		if item not in a:
			break
	else:
		count += 1
print(count)


(n, k) = map(int, input().split())
ks = ''
cnt = 0
for i in range(k + 1):
	ks = ks + str(i)
ks = set(ks)
for i in range(n):
	sa = input()
	sa = set(sa)
	if ks.issubset(sa):
		cnt = cnt + 1
print(cnt)


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) = (int(i) for i in input().split())
sol = 0
set1 = set((str(i) for i in range(k + 1)))
for i in range(n):
	set2 = set(input())
	if set1.issubset(set2):
		sol += 1
print(sol)


def is_good(number, k):
	numbers = [x for x in range(k + 1)]
	for item in numbers:
		if not str(item) in str(number):
			return False
	return True
numbers = [int(i) for i in input().split()]
k = numbers[1]
n = numbers[0]
total = 0
for x in range(n):
	if is_good(int(input()), k):
		total += 1
print(total)


(n, k) = map(int, input().split())
counter = 0
for i in range(n):
	a = set([int(j) for j in input()])
	ks = {j for j in range(k + 1)}
	if ks.issubset(a):
		counter += 1
print(counter)


(n, k) = list(map(int, input().split()))
count = 0
setk = {str(x) for x in range(k + 1)}
for x in range(n):
	a = set(input())
	if a >= setk:
		count += 1
print(count)


s = input().split()
x = int(s[0])
y = int(s[1])
m = 0
for i in range(x):
	n = 1
	q = [0] * (y + 1)
	z = input()
	for a in z:
		a = int(a)
		if a <= y:
			q[a] += 1
	for a in q:
		if a == 0:
			n = 0
			break
	if n:
		m += 1
print(m)


(n, k) = map(int, input().split())
mot = 0
for _ in range(n):
	q = [int(i) for i in input()]
	q = sorted(list(set(q)))
	if len(q) > k and q[k] == k:
		mot += 1
print(mot)


from ctypes import c_longlong as ll
(n, k) = map(int, input().split())
arr = []
count = 0
flag = 1
for i in range(0, n):
	num = int(input(''))
	mystr = str(num)
	for j in range(0, k + 1):
		j_str = str(j)
		if j_str in mystr:
			flag = 1
		else:
			flag = 0
			break
	if flag == 1:
		count += 1
print(count, '\n')


def check(n, a):
	d = {i: 0 for i in range(a + 1)}
	for i in n:
		d[int(i)] = 1
	for i in d:
		if not d[i]:
			return 0
	return 1

def solve():
	(n, k) = map(int, input().split())
	res = 0
	for _ in range(n):
		s = input()
		res += check(s, k)
	print(res)
solve()


def getTheGoodNumbersCount(n, k, nums):
	counter = 0
	for num in nums:
		range_list = list(range(k + 1))
		for digit in num:
			if int(digit) in range_list:
				range_list.remove(int(digit))
			else:
				continue
		if len(range_list) == 0:
			counter += 1
	return counter
(n, k) = input().split()
n = int(n)
k = int(k)
numbers = [None] * n
for i in range(n):
	numbers[i] = input()
print(getTheGoodNumbersCount(n, k, numbers))


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

def GoodNumber(num):
	for n in [chr(i) for i in range(ord('0'), ord(k) + 1)]:
		if n not in num:
			return False
	return True
print(sum([GoodNumber(input()) for i in range(int(n))]))


(n, k) = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	mark = set()
	s = [int(i) for i in input()]
	for digit in s:
		if digit <= k:
			mark.add(digit)
	if len(mark) == k + 1:
		ans += 1
print(ans)


hh = 0
(n, k) = input().split()
n = int(n)
k = int(k)
count = 0
string = ''
for i in range(0, n):
	number = input()
	for k in range(0, k + 1):
		string += str(k)
	for kl in range(0, len(string)):
		if string[kl] in number:
			count += 1
	if count == len(string):
		hh = hh + 1
	string = ''
	count = 0
print(hh)


(n, k) = list(map(int, input().split(' ')))
s = list(range(k + 1))
count = 0
ans = 0
for i in range(n):
	a = set(input())
	for j in s:
		if str(j) in a:
			count += 1
	if count == k + 1:
		ans += 1
	count = 0
print(ans)


from string import *
(m, n) = map(int, input().split())
(k, count, z) = ('0123456789', 0, '0' * 9)
for i in range(m):
	a = ''.join(sorted(set(input())))
	if k[0:n + 1] in a:
		count += 1
print(count)


def main():
	(n, k) = map(int, input().split())
	count = 0
	for _ in range(n):
		marked = [False for _ in range(k + 1)]
		for digit in input():
			if int(digit) > k:
				continue
			marked[int(digit)] = True
		if all(marked):
			count += 1
	print(count)
main()


(n, k) = map(int, input().split())
r = 0
while n:
	a = input()
	r += all((a.count(str(i)) for i in range(k + 1)))
	n -= 1
print(r)


(n, p) = input().split()
cn = 0
for i in range(int(n)):
	s = input()
	f = True
	for i in range(int(p) + 1):
		if s.count(str(i)) == 0:
			f = False
			break
	if f:
		cn += 1
print(cn)


(n, k) = map(int, input().split())
a = [set(map(int, input())) for _ in range(n)]
digits = {i for i in range(k + 1)}
c = 0
for i in range(n):
	if digits.issubset(a[i]):
		c += 1
print(c)


(n, k) = map(int, input().split())
nums = [input() for i in range(n)]
qtd = 0
for num in nums:
	x = list(set(list(map(str, num))))
	x.sort()
	s1 = ''.join(x)
	s2 = ''.join(list(map(str, list(range(k + 1)))))
	if s2 in s1:
		qtd += 1
print(qtd)


(n, k) = map(int, input().split())
ans = 0
k_set = set(range(k + 1))
for i in range(n):
	a = int(input())
	temp_set = set()
	while a != 0:
		temp = a % 10
		if temp in k_set:
			temp_set.add(temp)
		a = a // 10
	else:
		if k_set == temp_set:
			ans += 1
print(ans)


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)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, k) = lst()
	ans = 0
	for i in range(n):
		s = input()
		f = 1
		for d in range(k + 1):
			if str(d) not in s:
				f = 0
				break
		if f:
			ans += 1
	print(ans)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def isGood(a, k):
	mark = [False] * (k + 1)
	for i in a:
		t = int(i)
		if t <= k:
			mark[t] = True
	for i in mark:
		if i == False:
			return False
	return True

def main():
	(n, k) = invr()
	res = 0
	for _ in range(n):
		a = input()
		if isGood(a, k):
			res += 1
	print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


def solve(n, k):
	k1 = int(k)
	c = 0
	f = True
	while n:
		t = input()
		f = True
		for i in range(k1 + 1):
			if str(i) not in t:
				f = False
		if f:
			c += 1
		n -= 1
	print(c)
(n, k) = input().split()
solve(int(n), k)


(n, k) = map(int, input().split())
count = 0
for i in range(n):
	a = input()
	status = [0 for i in range(k + 1)]
	for i in a:
		value = int(i)
		if value <= k:
			status[value] = 1
	if sum(status) == k + 1:
		count += 1
print(count)


def valid(x, k):
	for item in L:
		if item not in x:
			return False
	return True
(n, k) = 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, k) = map(int, input().split())
l = []
p = [i for i in range(0, k + 1)]
count = 0
for i in range(n):
	put = input()
	l.append(put)
if k == 0:
	for i in l:
		s = []
		if '0' in i:
			count += 1
	print(count)
else:
	for i in l:
		s = []
		for j in p:
			if str(j) in i:
				s.append(j)
		s.sort()
		if s == p:
			count += 1
	print(count)


line1 = input().split()
n = int(line1[0])
k = int(line1[1])
good_number = set()
for i in range(k + 1):
	good_number.add(str(i))
good_counter = 0
for i in range(n):
	number = set(input())
	if good_number <= number:
		good_counter += 1
print(good_counter)


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	li = []
	for i in range(b + 1):
		li.append(0)
	t = input()
	flag = 0
	for j in range(len(t)):
		if int(t[j]) <= b:
			li[int(t[j])] = 1
	for j in range(b + 1):
		if li[j] == 0:
			flag = 1
			break
	if flag == 0:
		c += 1
print(c)


(n, k) = map(int, input().split())
s = 0
arr = [x for x in range(k + 1)]
r = list()
for i in range(n):
	a = [x for x in input()]
	a.sort()
	for j in a:
		if int(j) in arr:
			if int(j) not in r:
				r.append(int(j))
	if r == arr:
		s += 1
	r = list()
print(s)


(n, k) = str(input()).split()
n = int(n)
k = int(k)
note = [0 for i in range(10)]
num = 0
for i in range(n):
	for j in range(k + 1):
		note[j] = 1
	line = str(input())
	for it in line:
		note[int(it)] = 0
	if sum(note) == 0:
		num += 1
print(num)


(n, k) = map(int, input().split())
s = ''
a = []
for i in range(0, k + 1):
	s = s + str(i)
for i in range(n):
	z = input()
	z = set(z)
	z = sorted(z)
	a.append(''.join(z))
l = 0
for i in range(n):
	if str(s) in a[i]:
		l += 1
print(l)


def check(num, k):
	contains = [False] * (k + 1)
	while num > 0:
		if num % 10 <= k:
			contains[num % 10] = True
		num = num // 10
	return all((contains[i] for i in range(k + 1)))

def main():
	(n, k) = map(int, input().split())
	count = 0
	for _ in range(n):
		num = int(input())
		if check(num, k):
			count += 1
	print(count)
main()