#P1263D. Secret Passwords

    ID: 2003 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>dfs and similardsugraphs*1500

Secret Passwords

No submission language available for this problem.

Description

One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of nn passwords — strings, consists of small Latin letters.

Hacker went home and started preparing to hack AtForces. He found that the system contains only passwords from the stolen list and that the system determines the equivalence of the passwords aa and bb as follows:

  • two passwords aa and bb are equivalent if there is a letter, that exists in both aa and bb;
  • two passwords aa and bb are equivalent if there is a password cc from the list, which is equivalent to both aa and bb.

If a password is set in the system and an equivalent one is applied to access the system, then the user is accessed into the system.

For example, if the list contain passwords "a", "b", "ab", "d", then passwords "a", "b", "ab" are equivalent to each other, but the password "d" is not equivalent to any other password from list. In other words, if:

  • admin's password is "b", then you can access to system by using any of this passwords: "a", "b", "ab";
  • admin's password is "d", then you can access to system by using only "d".

Only one password from the list is the admin's password from the testing system. Help hacker to calculate the minimal number of passwords, required to guaranteed access to the system. Keep in mind that the hacker does not know which password is set in the system.

The first line contain integer nn (1n21051 \le n \le 2 \cdot 10^5) — number of passwords in the list. Next nn lines contains passwords from the list – non-empty strings sis_i, with length at most 5050 letters. Some of the passwords may be equal.

It is guaranteed that the total length of all passwords does not exceed 10610^6 letters. All of them consist only of lowercase Latin letters.

In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.

Input

The first line contain integer nn (1n21051 \le n \le 2 \cdot 10^5) — number of passwords in the list. Next nn lines contains passwords from the list – non-empty strings sis_i, with length at most 5050 letters. Some of the passwords may be equal.

It is guaranteed that the total length of all passwords does not exceed 10610^6 letters. All of them consist only of lowercase Latin letters.

Output

In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.

Samples

Sample Input 1

4
a
b
ab
d

Sample Output 1

2

Sample Input 2

3
ab
bc
abc

Sample Output 2

1

Sample Input 3

1
codeforces

Sample Output 3

1

Note

In the second example hacker need to use any of the passwords to access the system.