Problem6657--ABC249 — C - Just K

6657: ABC249 — C - Just K

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

You are given $N$ strings $S_1,S_2,\dots,S_N$ consisting of lowercase English alphabets.
Consider choosing some number of strings from $S_1,S_2,\dots,S_N$.
Find the maximum number of distinct alphabets that satisfy the following condition: "the alphabet is contained in exactly $K$ of the chosen strings."

Input

Input is given from Standard Input in the following format:
$N\ K$
$S_1$
$S_2$
$\vdots$
$S_N$

Output

Print the answer.

Constraints

$1≤N≤15$
$1 \le K \le N$
$N$ and $K$ are integers.
$S_i$ is a non-empty string consisting of lowercase English alphabets.
For each integer $i$ such that $1 \le i \le N$, $S_i$ does not contain two or more same alphabets.
If $i \neq j$, then $S_i \neq S_j$.

Sample 1 Input

4 2
abi
aef
bc
acg

Sample 1 Output

3
When $S_1,S_3$, and $S_4$ are chosen, a,b, and c occur in exactly two of the strings.
There is no way to choose strings so that $4$ or more alphabets occur in exactly $2$ of the strings, so the answer is $3$.

Sample 2 Input

2 2
a
b

Sample 2 Output

0

Sample 3 Input

5 2
abpqxyz
az
pq
bc
cy

Sample 3 Output

7

Source/Category