n = int(input())
t = []
for i in range(n):
    h = int(input())
    m = int(input())
    t.append([h * 60 + m, -1])
    t.append([t[-1][0] + 120, 1])
t.sort()
count = 0
max_count = 0
for p in t:
    x = p[0]
    type_x = p[1]
    count -= type_x
    if count > max_count:
        max_count = count
print(max_count)
