# 7:10 -> 710
from functools import reduce

def timeToMin(time):
    return int(time.replace(':', ''))

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(700, 901)
)

print(max(0, 3 - best))
