#C2630. Wordville Alliances

    ID: 45968 Type: Default 1000ms 256MiB

Wordville Alliances

Wordville Alliances

In the city of Wordville, every citizen is identified by a unique name. Two citizens are considered direct allies if their names share at least one common character. An alliance is a group of citizens that is connected directly or indirectly through shared characters.

More formally, consider a graph where each citizen is a vertex, and an edge exists between two vertices if the corresponding names share at least one common letter. The number of alliances is the number of connected components in this graph. Moreover, if two citizens are connected by a series of direct alliances, they belong to the same alliance.

Your task is to compute the number of distinct alliances formed by the given list of citizen names.

inputFormat

The input is read from standard input (stdin) and has the following format:

 n
 name1
 name2
 ...
 namen

Where n is an integer representing the number of citizens, followed by n lines, each containing a string name. Each name consists of lowercase English letters, and its length can be large.

outputFormat

Output to standard output (stdout) a single integer which is the number of alliances formed.

## sample
5
alice
bob
charlie
david
ed
2