#include <bits/stdc++.h>
using namespace std;
int n,b,sum=0,f[2000008],a[21];
int gain()
{
freopen("shelf2.in","r",stdin);
freopen("shelf2.out","w",stdout);
scanf("%d%d",&n,&b);
for (int q=1;q<=n;q++) {
scanf("%d",&a[q]);
sum+=a[q];
}
int W=sum-b;
f[0]=0;
for (int q=1;q<=n;q++) {
for (int w=W;w>=a[q];w--) {
f[w]=max(f[w],f[w-a[q]]+a[q]);
}
}
printf("%d\n",W-f[W]);
return 0;
}
int ss=gain();
int main(){;}