import java.util.*; public class Main { static int n; static int k; static int[] arr; public static void main (String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } System.out.println(search(0, 0)); } static int search(int idx, int weight) { if (idx >= n) { return weight; } int ans = weight; if (weight + arr[idx] <= k) { ans = search(idx + 1, weight + arr[idx]); } ans = Math.max(ans, search(idx + 1, weight)); return ans; } }