Program Pr1;
uses crt;
var ch,min,sek,ch2,min2,sek2,a,b,c:integer;
Begin
clrscr;
a:=0;
b:=0;
readln(ch,min,sek,ch2,min2,sek2);
while a<=ch do begin<br> a:=a+1;
b:=b+3600;
c:=b;
end;
b:=b+min*60+sek;
while a<=ch2 do begin<br> a:=a+1;
c:=c+3600;
end;
c:=c+min2*60+sek2;
writeln(c-b);
end.