poj3628


import java.util.Scanner;

public class Main {
   
    public static void main(String[] args) {
   
        int n,b;
        final int N=25,MAX=20000020,INF=0x3f3f3f3f;
        int[] h=new int[N];
        int[] dp=new int[MAX];
        int sum=0;
        int ans=INF;
        Scanner cin=new Scanner(System.in);
        n=cin.nextInt();
        b=cin.nextInt();
        for(int i=0;i<n;i++){
   
            h[i]=cin.nextInt();
            sum+=h[i];
        }
        for(int i=0;i<n;i++){
   
            for(int j=sum;j>=h[i];j--){
   
                dp[j]=Math.max(dp[j],dp[j-h[i]]+h[i]);
                if(dp[j]>=b){
   
                    ans=Math.min(ans,dp[j]);
                }
            }
        }
        System.out.println(ans-b);
    }
}