package m.shin; import java.util.Arrays; import java.util.Scanner; public class Con617 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt() , K = s.nextInt(); int[] A = new int[N]; for(int i = 0;i < N;i++){ A[i] = s.nextInt(); } s.close(); Arrays.sort(A); //System.out.println(a[0] + " " + a[1]); int max = 0; int[][] d = new int[K+1][2]; d[0][0] = 1; for(int i = 0;i <= K;i++){ if(d[i][0] == 1){ for(int j = d[i][1];j < N;j++){ int add = A[j]; if(i + add <= K){ d[i + add][0] = 1; if(d[i + add][1] != 0){ d[i + add][1] = Math.min(Math.min(j+1, d[i+add][1]), N); }else{ d[i + add][1] = Math.min(j + 1, N); } max = Math.max(max, i + add); } } } } System.out.println(max); } }