#abc249c. [abc249_c]Just K
[abc249_c]Just K
Problem Statement
You are given strings consisting of lowercase English alphabets.
Consider choosing some number of strings from .
Find the maximum number of distinct alphabets that satisfy the following condition: "the alphabet is contained in exactly of the chosen strings."
Constraints
- and are integers.
- is a non-empty string consisting of lowercase English alphabets.
- For each integer such that , does not contain two or more same alphabets.
- If , then .
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 2
abi
aef
bc
acg
Sample Output 1
3
When , and are chosen, a
,b
, and c
occur in exactly two of the strings.
There is no way to choose strings so that or more alphabets occur in exactly of the strings, so the answer is .
Sample Input 2
2 2
a
b
Sample Output 2
0
You cannot choose the same string more than once.
Sample Input 3
5 2
abpqxyz
az
pq
bc
cy
Sample Output 3
7