program p1;
var fi,fo:text;
total,n,w,i,j,x:integer;
a:array[1..1010,1..2] of integer;
t:array[-1..1010,-1..1010]of integer;
ok:boolean;
procedure citire;
begin
read(fi,n,w);
for i:=1 to n do
begin
read(fi,a[i,1],a[i,2]);
total:=total+a[i,2];
end;
if total<w then begin writeln(fo,'-1'); close(fi); close(fo); halt; end;
end;
BEGIN
assign(fi,'energii.in'); reset(fi);
assign(fo,'energii.out'); rewrite(fo);
citire;
x:=0;
while (x<=w)or(t[0,x]=0) do
begin
inc(x);
ok:=true;
for i:=1 to n do
if (ok)and(x-a[i,1]>=0)or(x-a[i,1]>=0)and(t[i,x]=0)and(t[0,x-a[i,1]]+a[i,2]<t[0,x]) then
if (x-a[i,1]=0)or(x-a[i,1]<>0)and(t[0,x-a[i,1]]<>0)then
begin
t[0,x]:=t[0,x-a[i,1]]+a[i,2];
for j:=1 to n do t[j,x]:=t[j,x-a[i,1]];
t[i,x]:=1;
ok:=false;
end;
end;
writeln(fo,t[0,x]);
close(fi); close(fo);
END.