Trimming Strings

Time limit1sMemory limit256 MB

Problem

You are given a table with R rows and C columns. Every cell contains a lowercase English letter.

For each column, reading its characters from top to bottom forms one string. A single operation removes the current top row of the table. If, after that removal, all C column strings are still pairwise different, the removal is kept and count increases by 1. If any two column strings become the same, the process stops and count is printed.

The initial table is guaranteed to have pairwise different column strings. Determine the final value of count.

Input

The first line contains two integers R and C, the number of rows and columns of the table. (2 <= R, C <= 1000)

The next R lines each contain C lowercase English letters. In the initial table, the strings obtained by reading each column from top to bottom are all pairwise different.

Output

Print the value of count described above.