using System; using System.Collections.Generic; using System.Linq; public class Program { static void Main() { int Width = int.Parse(Console.ReadLine()); Console.ReadLine(); var ValueList = (Console.ReadLine()).Split(' ').Select(int.Parse).OrderBy(a => a); int Count = 0; foreach(var ItemW in ValueList){ if((Width -= ItemW) >= 0 ){ Count++; } } Console.WriteLine(Count); } static IEnumerable GetChar(){ int Moji = 0; int Count = 1; char tmp = (char)0; while((Moji = Console.Read()) != -1){ if(Moji <65 || Moji >90){ break; } tmp = (char)(( Moji - 65 + 26 - Count)%26 + 65); yield return tmp; Count = (Count + 1)%26; } } static void WriteLine (T dsads){ } }