n = int(input())

def f():
    i = input()
    return (int(i[0]) - 7) * 60 + int(i[2:])

alarms = sorted([f() for _ in range(n)])

print(max(0, 3 - max(sum(1 for j in alarms if j in range(i, i + 11)) for i in alarms)))