# Start from 7:01
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 + 1, 9 * 60)
)

print(max(0, 3 - best))
