const inf=99999;
var g,w:integer;
e,c:array[1..1001] of integer;
i,j,k:integer;
a,b:array[1..5001] of longint;
begin
assign(input,'energii.in');
assign(output,'energii.out');
reset(input);
rewrite(output);
readln(g);
readln(w);
for i:=1 to g do
begin
read(e[i]); readln(c[i]);
end;
for i:=1 to w do
begin
a[i]:=inf;
b[i]:=inf;
end;
for i:=1to g do
if a[e[i]]>c[i] then a[e[i]]:=c[i];
for i:=1 to g do
begin
for k:=1 to w do
b[k]:=a[k];
for j:=1 to w do
if j-e[i]>0 then
if a[j]>b[j-e[i]]+c[i] then a[j]:=b[j-e[i]]+c[i];
end;
write(a[w]);
close(input);
close(output);
end.