inputs: Solve in Python:
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 $n$ 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 $a$ and $b$ as follows:  two passwords $a$ and $b$ are equivalent if there is a letter, that exists in both $a$ and $b$;  two passwords $a$ and $b$ are equivalent if there is a password $c$ from the list, which is equivalent to both $a$ and $b$. 

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.


-----Input-----

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

It is guaranteed that the total length of all passwords does not exceed $10^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...
targets: # from sys import stdin
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import sys
input = sys.stdin.readline

# t = int(input())
#
# for _ in range(t):
#     a,b,c = map(int,input().split())
#     a,b,c = sorted([a,b,c])
#     ans = 0
#     ans+=b
#     c-=b
#
#     a,c = sorted([a,c])
#     ans+=a
#     print(ans)


# print(ans)

def find_parent(u):
    if par[u]!=u:
        par[u]=find_parent(par[u])
    return par[u]




n = int(input())
la = []

hash = defaultdict(list)
par = [0]+[i+1 for i in range(26)]
rank = [1]*(26+1)
seti = set()
booli = [False]*(27)
for i in range(n):
       z = input()

       z = z[:len(z)-1]
       k = min(z)

       set1 = set(min(k))

       booli[ord(k) - 97 + 1] = True

       a = ord(k) - 97 + 1
       z2 = find_parent(a)
       for i in range(len(z)):
           booli[ord(z[i]) - 97 + 1] = True


           if z[i] not in set1 :

             b = ord(z[i]) - 97 + 1
             z1 = find_parent(b)
             if z1!=z2:
               par[z1] = z2

             set1.add(i)

ans = set()

for i in range(26):
        if booli[i+1] == True:
           # print(chr(i+98))
           z = find_parent(i+1)
           ans.add(z)

print(len(ans))