package tmp; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } int ans = 0; for (int s = 0; s < 1 << N; ++s) { int tmp = 0; for (int i = 0; i < N; ++i) { if ((s >> i) % 2 == 1) { tmp += A[i]; } } if (tmp <= K) { ans = Math.max(ans, tmp); } } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }