<Problem>
http://ntucoder.net/Problem/Details/4
USES CRT;
type Arr=array[0..1000000] of longint;
var n,m,i,res:longint;
a:Arr;
PROCEDURE SORT (var a:Arr; l,r:longint);
var i,j,x,tg:longint;
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 not (i>j) then begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
inc(i);
dec(j);
end;
until i>j;
if l<j then SORT(a,l,j);
if i<r then SORT(a,i,r);
end;
begin
readln(n,m);
for i:=1 to n do read(a[i]);
SORT(a,1,n);
res:=1; i:=0;
for i:=1 to n+1 do begin
if res>=m then break;
res:=res+a[i]-1;
end;
if i<=n then writeln(i-1) else writeln(-1);
readln;
end.