# boj, 1316 : 그룹 단어 체커, python3
# 구현, 문자열 알고리즘
import sys


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1

    return result


N = int(sys.stdin.readline())

print(checker(N))
43ce8f0a40f3210270d5f5f58110ab498be969f6
<mask token>


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1
    return result


<mask token>

<mask token>


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1
    return result


<mask token>
print(checker(N))

<mask token>


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1
    return result


N = int(sys.stdin.readline())
print(checker(N))

import sys


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1
    return result


N = int(sys.stdin.readline())
print(checker(N))

# boj, 1316 : 그룹 단어 체커, python3
# 구현, 문자열 알고리즘
import sys


def checker(n):
    result = 0
    for _ in range(n):
        word = str(input())
        if list(word) == sorted(word, key=word.find):
            result += 1

    return result


N = int(sys.stdin.readline())

print(checker(N))