var
hi:array[1..20]of longint;
b,h,total:longint;
n,i:byte;
procedure search(k:byte);
var
i:byte;
begin
if h>=b then
if (h-b)<total then total:=h-b
else exit;
for i:=k+1 to n do
begin
h:=h+hi[i];
search(i);
h:=h-hi[i];
end;
end;
Begin
assign(input,'shelf2.in');reset(input);
assign(output,'shelf2.out');rewrite(output);
readln(n,b);
for i:=1 to n do readln(hi[i]);
h:=0; total:=maxint;
search(0);
write(total);
close(input);close(output);
end.