params = input().split("\n")
n = int(params[0])
strings = params[1:]
# sort into arrays based on length
harmonic_potential = {}
for string in strings:
str_len = len(string)
if not str_len in harmonic_potential:
harmonic_potential[str_len] = []
harmonic_potential[str_len].append(string)
harmonic_count = 0
harmonics = []
for str_list in harmonic_potential.values():
for index, string in enumerate(str_list):
same_char = [] # [ [pos1, pos2] ]
diff_char = []
for pos, char in enumerate(string):
for other_pos in range(pos + 1, len(string)):
other_char = string[other_pos]
if char == other_char:
same_char.append([pos, other_pos])
else:
diff_char.append([pos, other_pos])
for other_index in range(index + 1, len(str_list)):
other_string = str_list[other_index]
if other_index != index:
is_harmonic = True
for same_char_info in same_char:
pos0 = same_char_info[0]
pos1 = same_char_info[1]
if other_string[pos0] != other_string[pos1]:
is_harmonic = False
break
for diff_char_info in diff_char:
pos0 = diff_char_info[0]
pos1 = diff_char_info[1]
if other_string[pos0] == other_string[pos1]:
is_harmonic = False
break
if is_harmonic:
harmonic_count += 1
harmonics.append((string, other_string))
print(harmonic_count)
#print(harmonics)
# 6 AAB ABKA SSG TSGT ZZZZ KEAK
# 10 AB CD AAB DDS EET QWEE RRTA EIOP PPAB IPAA
# 4