JOI decided to make a signboard for the shop. There are N pieces of his old signboards with characters written at regular intervals. JOI makes a sign by erasing some characters from an old sign. I want the remaining character string to be the name of the store, and the remaining characters to be arranged at regular intervals. The sign he must make from a single old sign, and must not cut or splice old signs. Write a program to calculate the number of billboards that JOI can make given the name of the shop and the information of her N old billboards. However, even if multiple signboards can be made from one old signboard, only one signboard can be made.
n = int(input())
s = input()
t = [input() for i in range(n)]
c = 0
for tt in t:
	f = False
	for i in range(len(tt)):
		for j in range(len(tt))[1:]:
			print(tt[i::j][:len(s)])
			f |= s == tt[i::j][:len(s)]
	if f: c += 1
print(c)
n = int(input())
s = input()
t = [input() for i in range(n)]
c = 0
for tt in t:
	f = False
	for i in range(len(tt)):
		for j in range(len(tt))[1:]:
			f |= s == tt[i::j][:len(s)]
	if f: c += 1
print(c)