ZNANSTVE  ZNANSTVENIK
In this economy, we all know how hard it is to get a job. Mirko, a recent college graduate, however, got lucky  he is now employed as a runeologist by the Language Institute of Croatia. His friend Slavko believes runeology isn’t a science and is hence angry at Mirko for believing the opposite. One foggy Christmas day, Mirko’s laptop broke. Since he isn’t great with computers, he gave it to Slavko to repair it. Slavko, feeling a little naughty, decided to mess up a particular file Mirko was working on.
This file contains a matrix of R rows and C columns. Each element of the matrix is a single letter. No two columns of the matrix are equal. To have some fun with pseudoscientist Mirko, Slavko decided he will delete as many rows as possible from the top of the table, without breaking the noequalcolumn rule.
Input
The first line of input contains two integers R and C (2 ≤ R, C ≤ 1000), the number of rows and the number of columns, respectively.
In each of the next R lines there are C small letters of the English alphabet. These R x C letters represent Mirko’s table (which does not have two columns the same.)
Output
Output a single integer, the maximum number of rows which can be deleted from the top of the table so that no two columns are equal.
Example
Input: 2 6 dobarz adatak Output: 0
Input: 3 4 alfa beta zeta Output: 2
Input: 4 6 mrvica mrvica marica mateja Output: 1
hide comments
nadstratosfer:
20190408 16:18:09
There are blanklines between rows, nasty trap for linereading languages when input is made of strings! 

vengatesh15:
20170917 18:50:07
Finally AC after so many attempts. 

Shakil Ahmed:
20131105 10:45:16
Try this input :


Gaurav:
20130830 12:57:23
easy pgm in python but i am getting tle :( 

Narendra yadav:
20130626 16:20:21
Getting wrong in 9th case ..pl suggest.


Amit RC:
20130623 19:00:51
the only difference between my second last and third last submissions is declaring the variable max as local and global...yet one gives TLE while other gives WA..how is that possible? 

adhikari vushesh babu:
20130303 16:42:49
simple got acc :)by brute force 

Secret:
20130124 11:23:03
brute force is accepted :P 

:D:
20120215 07:30:27
If you delete row 1 and 2, columns 1 and 6 will be identical with "aa", so you can delete only one. 

hibernating:
20120214 21:25:06
what is meant by "top of the table"

Added by:  islam 
Date:  20120213 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  COCI 2010/2011 Contest 1 by Adrian Satja Kurdija 