var
n,s,a,sum,i,j:longint;
c,y:array[1..10000]of longint;
fin,fout:text;
begin
assign(fin,'factory.in');reset(fin);
assign(fout,'factory.out');rewrite(fout);
read(fin,n,s);
for i:=1 to n do
read(fin,c[i],y[i]);
sum:=c[1]*y[1];
for i:=2 to n do begin
a:=5;j:=0;
repeat
inc(j);
if c[i]-a>c[i-j] then c[i]:=c[i-j]+a;
a:=a+5;
until i-j=1;
end;
for i:=2 to n do
sum:=c[i]*y[i]+sum;
write(fout,sum);
close(fin);
close(fout);
end.