Connected components in word graphs

This is closely related to the previous problem. You are given the same set of 5 letter words and your task is to the find out the number of connected components in that graph.

Input

The first line of input contains a single integer n (n<6000). Each of the next n lines contains a five letter word.

Output

Print out the number of connected components of the graph you constructed.

Sample Input

6
aaaaa
aaaab
aaaac
ccccd
cccce
aaabb

Sample Output

2