#d11104. 删库
删库
Deleting the Database
Problem Description
There are strings. In one operation, you may choose any string (which may be empty, and is not necessarily among the given strings). Then consider all strings that have not been deleted yet; if is a prefix of (the empty string is a prefix of any string), add to the candidate deletion set.
However, at most strings may be deleted in one operation: if the candidate set contains more than strings, nothing happens. Otherwise, all strings in the candidate set are deleted.
Find the minimum number of operations needed to delete all the strings.
Input Format
The first line contains two positive integers and , as described above.
The next lines each contain one string consisting only of lowercase English letters.
It is guaranteed that no two strings are identical.
For all test cases, , , and (the sum of the lengths of all strings).
Output Format
Output one line containing a single positive integer: the minimum number of operations needed to delete all the strings.
Sample Input 1
4 2
a
abc
abd
b
Sample Output 1
2
Sample Input 2
4 2
d
c
ab
a
Sample Output 2
2
Sample Input 3
5 3
please
remove
all
these
files
Sample Output 3
3
Sample Explanation
In the first test case, in the first operation we choose ab, deleting abc and abd. In the second operation we choose the empty string, deleting all the remaining strings.