<Problem>
http://ntucoder.net/Problem/Details/3351
Uses Crt;
var a,b:array[-10..1000000] of int64;
n,i,time,num1,num2,max,t1,t2:longint;
Procedure hoanvi(var a,b:int64); var tg:int64; begin tg:=a; a:=b; b:=tg; end;
Procedure Sort(l,r:longint);
var i,j:longint; x:int64;
begin
i:=l; j:=r; x:=a[(l+r) div 2];
repeat
while a[i]<x do inc(i); while (a[j]>x) do dec(j);
if i<=j then begin Hoanvi(a[i],a[j]); hoanvi(b[i],b[j]); inc(i); dec(j) end;
until i>j;
if j>l then sort(l,j); if i<r then sort(i,r);
end;
Begin
readln(n);
for i:=1 to n do
begin
read(a[i],a[i+n],t1,t2);
num1:=t1 mod 100+t1 div 100 mod 100*60+t1 div 10000*3600;
num2:=t2 mod 100+t2 div 100 mod 100*60+t2 div 10000*3600;
time:=num2-num1;
if time<0 then time:=time+86400; //Goi sang tan ngay hom sau
b[i]:=2*time; //Chi so thoi gian nguoi goi
b[i+n]:=time; //Chi so thoi gian nguoi nhan cuoc goi
end;
sort(1,n*2); //Vi nguoi goi hoac nguoi nhan co the goi nhieu lan trong ngay nen phai sap xep lai
max:=0;
for i:=1 to n*2 do
begin
if a[i]=a[i-1] then b[i]:=b[i]+b[i-1];
if b[i]>max then max:=b[i];
end;
writeln(max);
readln;
End.