import sys

def fce(slovo1, slovo2):
	for c in str(slovo1):
		if c not in str(slovo2):
			return False
	return True


delka = sys.stdin.readline()
slovnik = []
for i in range(0, int(delka)):
	i += 1
	slovnik.append( int(sys.stdin.readline()))

slovnik.sort()
completeList = []
usedList = []

for index1,element1 in enumerate(slovnik):
	tempList = []
	if index1 not in usedList:
		usedList.append(index1)
		tempList.append(element1)

		for index2,element2 in enumerate(slovnik):
			if ((index2 not in usedList) and fce(element1, element2)):
				tempList.append(element2)
				usedList.append(index2)
		completeList.append(tempList)

print(len(completeList))

