using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; class Program { static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var sc = new Scan(); int c = sc.Int; int n = sc.Int; var w = new int[n]; var dp = new int[1 << n]; var pl = new List(); for (int i = 0; i < n; i++) w[i] = sc.Int; for (int i = 1; i < (1 << n); i++) { int s = 0; for (int j = 0; j < n; j++) if ((i >> j & 1) == 1) s += w[j]; if (s <= c) { pl.Add(i); dp[i] = 1; continue; } dp[i] = n; foreach (var j in pl) if ((i & j) == j) dp[i] = Math.Min(dp[i], dp[i ^ j] + 1); } sw.WriteLine(dp[(1 << n) - 1]); sw.Flush(); } } class Scan { public int Int { get { return int.Parse(Str); } } public long Long { get { return long.Parse(Str); } } public string Str { get { return Console.ReadLine().Trim(); } } public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } } public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } } public string[] StrArr { get { return Str.Split(); } } }