# Ends 8:59
from functools import reduce

def timeToMin(time):
    h, mm = map(int, time.split(':'))
    return h * 60 + mm

n = int(input())
alarms = [timeToMin(input()) for _ in range(n)]

best = max(
    len(list(alarm for alarm in alarms if start <= alarm <= start + 10)) 
    for start in range(7 * 60, 9 * 60 - 10)
)

print(max(0, 3 - best))
