https://www.acmicpc.net/problem/1062
import sys
from itertools import combinations
def solution():
read = sys.stdin.readline
n, k = map(int, read().split())
words = [read().rstrip()[4:-4] for _ in range(n)]
# antatica를 선택할수 없으면 0
if k < 5:
print(0)
return
already = set('antatica')
chars = [chr(ord('a')+i) for i in range(26) if chr(ord('a')+i) not in already]
max_count = float('-inf')
# chars 중에서 k-5개 선택
for combi in combinations(chars, k-5):
sett = already | set(combi)
count = 0
for word in words:
possible = True
# words 중에 하나라도 불가능하면 break
for i in range(len(word)):
if word[i] not in sett:
possible = False
break
if possible:
count += 1
max_count = max(max_count, count)
print(max_count)
solution()