You are given N uppercase words, each of length 2K.
A Kokos is a directed graph whose vertices each contain one letter. Every given word must be readable along some path in the graph. In other words, if you write down the letters on that path in order, they must exactly form the word.
For the length-2K path representing any word, the vertices on the path must satisfy these conditions.
0.K - 1 vertices have in-degree 1.K - 1 vertices have out-degree 1.0.Therefore, the first K letters of a word may branch, and the last K letters may merge.
Find the minimum possible number of vertices in a Kokos that can represent all N given words.
The first figure below shows one minimum-size Kokos satisfying the conditions.

The second graph below uses fewer vertices, but it is not a Kokos.

It fails because paths merge at the fourth letter D and then split again at the sixth letter E, violating the required conditions.
The first line contains N and K. (1 <= N <= 10,000, 1 <= K <= 100)
Each of the next N lines contains one uppercase English word of length 2K.
Print the minimum possible number of vertices in a Kokos that can represent all given words.