n = int(input()) s = [input() for i in range(n)] bool_list = [] for i in range(n - 1): bool_list.append(((s[i] + 1) == s[i + 1]) or ((s[i] - 1) == s[i + 1])) print((n - 1) == bool_list.count(True))