#include<cstdio>
#include<iostream>
using namespace std;
inline long long get();
void dfs(long long sum,int now);
bool jud[21];
long long n,b;
long long len[21];
long long ans=0x7ffffffff;
int main()
{
freopen("shelf2.in","r",stdin);
freopen("shelf2.out","w",stdout);
n=get(),b=get();
for(int i=1;i<=n;i++)len[i]=get();
dfs(0,1);
printf("%lld",ans);
return 0;
}
void dfs(long long sum,int now)
{
if(sum>=b)
{
ans=min(sum-b,ans);
return;
}
for(int i=now;i<=n;i++)
{
dfs(sum+len[i],i+1);
}
}
inline long long get()
{
long long t=0;char c=getchar(),j=1;
while(!isdigit(c))
if(c=='-')j=-1,c=getchar();
else c=getchar();
while(isdigit(c))
t=(t<<3)+(t<<1)+c-'0',
c=getchar();
return j*t;
}