atcoder#ABC249C. [ABC249C] Just K
[ABC249C] Just K
Score : points
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.
4 2
abi
aef
bc
acg
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 .
2 2
a
b
0
You cannot choose the same string more than once.
5 2
abpqxyz
az
pq
bc
cy
7