S = 0 for _ in range(int(input())) : string = input() if list(string) == sorted(string,key=string.find) : S+=1 print(S)