import sys

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

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

		for index1,element1 in enumerate(slovnik):
			if index1 not in usedList:
				usedList.append(index1)
				for index2,element2 in enumerate(slovnik, start=index1+1):
					if ((index2 not in usedList)):
						aaaaa = True
						for c in str(element1):
							if c not in str(element2):
								aaaaa = False
						if aaaaa:						
							usedList.append(index2)
				completeList += 1

		print(completeList)
	except:
		break

