An ab-word is any sequence of the lowercase letters a and b, including the empty sequence. If X=[x1,…,xn] is an ab-word and 1≤i≤j≤n, then X[i..j] denotes the subword xi,…,xj.
An ab-word X=[x1,…,xn] is nice if it has exactly as many a's as b's, and for every i=1,…,n the prefix X[1..i] has at least as many a's as b's.
The similarity of nice ab-words is defined inductively:
The level of diversity of a non-empty set S of nice ab-words is the largest number of words that can be chosen from S so that no two chosen words are similar to each other.
Write a program that reads the set S from standard input, computes the level of diversity of S, and writes the result to standard output.
The first line contains an integer n, the number of elements of the set S (1≤n≤1000). Each of the next n lines contains one element of S, that is, a nice ab-word. Every word starts at the beginning of its line and has no spaces between consecutive letters. The length of each ab-word is between 1 and 200.
Output a single integer: the level of diversity of S.