import sys
input = sys.stdin.readline
k = [chr(i) for i in range(ord('a'), ord('z') + 1)]
v = '22233344455566677778889999'
matched_char = dict(zip(k, v))
N = int(input())
word_list = [input().rstrip() for _ in range(N)]
S = input().rstrip()
length = len(S)
count = 0
for word in word_list:
if len(word) != length:
continue
formatted_word = ''.join([matched_char[char] for char in word])
if formatted_word == S:
count += 1
print(count)