import sys

input = lambda: sys.stdin.readline().rstrip()


def back_tracking(k, word_letters, learned_ch, index, length):
    if length == k - 5:
        count = 0  # 배울 수 있는 단어 개수
        for word in word_letters:
            flag = True
            for ch in word:
                if not learned_ch[ord(ch) - ord('a')]:
                    flag = False
                    break

            if flag:
                count += 1
        return count

    result = 0
    for i in range(index, 26):
        if not learned_ch[i]:
            learned_ch[i] = True
            new_result = back_tracking(k, word_letters, learned_ch, i, length + 1)
            result = max(result, new_result)
            learned_ch[i] = False

    return result


def solution(n, k, word_letters):
    if k < 5:
        return 0
    if k == 26:
        return n

    learned_ch = [False for _ in range(26)]
    for ch in "antic":
        learned_ch[ord(ch) - ord('a')] = True

    return back_tracking(k, word_letters, learned_ch, 0, 0)


if __name__ == "__main__":
    n, k = map(int, input().split())
    word_letters = [set(input()) for _ in range(n)]

    print(solution(n, k, word_letters))

assert (solution(3, 6, ["antarctica", "antahellotica", "antacartica"]) == 2)
assert (solution(2, 3, ["antaxxxxxxxtica", "antarctica"]) == 0)
assert (solution(9, 8, ["antabtica", "antaxtica", "antadtica", "antaetica", "antaftica",
                        "antagtica", "antahtica", "antajtica", "antaktica"]) == 3)
