using System; using System.Collections.Generic; using System.Linq; namespace y { class Program { static void Main(string[] args) { string[] ss = Console.ReadLine().Split(); int n = int.Parse(ss[0]); int k = int.Parse(ss[1]); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(Console.ReadLine()); } var li = new List(); li.Add(0); for (int i = 0; i < n; i++) { int c = li.Count; for (int j = 0; j < c; j++) { li.Add(li[j] + a[i]); } } Console.WriteLine(li.Where(x => x <= k).Max()); } } }