list를 제자리에서(in-place) 수정하는 내장 list.sort() 메서드
iterable로부터 새로운 정렬된 리스트를 만드는 sorted() 내장 함수
key=word.find: 알파벳 순서가 아닌, 첫 등장한 위치부터 중복되는 단어 나열
result = 0
n = int(input())
for i in range(n):
word = input()
if list(word) == sorted(word, key=word.find):
result += 1
print(result)