using System; using System.Collections.Generic; class program { public static void Main() { var str = Console.ReadLine().Split(' '); var N = int.Parse(str[0]); var M = int.Parse(str[1]); str = Console.ReadLine().Split(' '); var C = new int[str.Length]; for (int i = 0; i < str.Length; i++) { C[i] = int.Parse(str[i]); } Array.Sort(C); for (int i = 0; i < C.Length; i++) { if (M - C[i] >= 0) { M -= C[i]; C[i] = 0; } else { C[i] -= M; M = 0; break; } } var count = 0; foreach (var i in C) { if (i == 0) count++; } Console.WriteLine(count); } }