num = int(input())
all_words = [list(input()) for n in range(num)]
result = 0
for n in range(num):
used = []
words = all_words[n]
check = True
for i in range(len(words)):
if i > 0 and words[i] in used and words[i] != words[i-1]:
check = False
break
used.append(words[i])
if check == True:
result += 1
print(result)