Niebieskie ksi.eczki
V Olimpiada Informatyczna 1997/1998

Task: ABS
Author: Krzysztof Diks
AB-words

I stage contest  

Every sequence of small letters a and b (also the empty sequence) is called an ab-word. If X=[x1,..,xn] is an ab-word and i,j are integers such that 1<=i<=j<=n then X[i..j] denotes the subword of X consisting of the letters xi,..,xj. We say that an ab-word X=[x1,..xn] is nice if it has as many letters a as b and for all i=1,...,n the subword X[1,i] has at least as many letters a as b.

Now, we give the inductive definition of the similarity between nice ab-words.

A level of diversity of a non-empty set S of nice ab-words is the maximal number of ab-words that can be chosen from S in such a way that for each pair w1,w2 of chosen words, w1 is not similar to w2.

Task

Write a program that:

Input

In the first line of the input file there is a number n of elements of the set S, 1<=n<=1000; in the following n lines there are elements of the set S, i.e. nice ab-words (one word in each line); the first letter of every ab-word is the first symbol in line and there are no spaces between two consecutive letters in the word; the length of every ab-word is an integer from the range [1..200].

Output

In the first and only line of the text file ABS.OUT there should be written one integer - the level of diversity of S.

Example

For the input file ABS.IN:

3
aabaabbbab
abababaabb
abaaabbabb

The correct answer is the output file ABS.OUT

2