package tester; import java.util.Arrays; import java.util.HashSet; 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(); if (!(1 <= N && N <= 20)) throw new AssertionError(); if (!(0 <= K && K <= 2000000)) throw new AssertionError(); int[] A = new int[N]; HashSet set = new HashSet<>(); for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); if (set.contains(A[i])) throw new AssertionError(); set.add(A[i]); if (!(1 <= A[i] && A[i] <= 100000)) throw new AssertionError(); } 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)); } }