It's time to elect a new student council!
There are
candidates who want to join the student council. Each of the
students submits a ballot containing a permutation of the given
candidates. Kaguya wants the council to be as large as possible so that she can spend less time doing administrative work and more time getting Miyuki to confess his love for her. However, because the council positions are ranked, Kaguya cannot simply put every candidate on the student council. In particular, if Kaguya puts candidate
and candidate
on the council, with candidate
ranked higher on the council than candidate
, then every student who submitted a ballot must have ranked candidate
higher than candidate
.
Compute the maximum possible size of the council Kaguya can generate.
Constraints


In tests worth 1 mark,
.
In tests worth an additional 4 marks,
.
Input Specification
The first line contains two integers,
and
.
Each of the next
lines contains a string of length
, consisting of a permutation of the first
uppercase letters.
Output Specification
Output the maximum possible size of the council.
Sample Input 1
Copy
2 3
BAC
ABC
Sample Output 1
Copy
2
Sample Input 2
Copy
3 8
HGBDFCAE
ADBGHFCE
HCFGBDAE
Sample Output 2
Copy
3
Sample Input 3
Copy
6 8
AHFBGDCE
FABGCEHD
AHDGFBCE
DABHGCFE
ABCHFEDG
DGABHFCE
Sample Output 3
Copy
4
Comments