type mas1 = array[0..1] of integer;
     mas2 = array [1..200000] of mas1;
var t:mas2;
    n, h, m:integer;
    i:integer;
    count, max_count, type_x, x:integer;


procedure sort(l, r: integer; var t: mas2);
// Быстрая сортировка   
var
  i, j, m: integer;
  y1, x1: mas1;
begin
  i := l;
  j := r;
  m := round((l + r) / 2);
  x1 := t[m];
  repeat
    while (t[i][0] < x1[0]) or (t[i][0] = x1[0]) and (t[i][1] < x1[1])  do inc(i);
    while (t[j][0] > x1[0]) or (t[j][0] = x1[0]) and (t[j][1] > x1[1]) do dec(j);
    if i <= j then
    begin
      y1 := t[i];
      t[i] := t[j];
      t[j] := y1;
      inc(i);
      dec(j);
    end;
  until i > j;
  if l < j then sort(l, j, t);
  if i < r then sort(i, r, t);
end;
    
    
begin

readln(n);
for i := 1 to n do
begin
  readln(h);
  readln(m);
  t[2 * i - 1][0] := h * 60 + m;
  t[2 * i - 1][1] := -1;
  t[2 * i][0] := t[2 * i - 1][0] + 120;
  t[2 * i][1] := 1;
end;

sort(1, 2 * n, t);

count := 0;
max_count := 0;
for i := 1 to 2 * n do
begin
    x := t[i][0];
    type_x := t[i][1];
    count -= type_x;
    if count > max_count then
    begin
         max_count := count;
    end;
end;
writeln(max_count);

end.