import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } Arrays.sort(arr); int left = 0; int right = n; while (right - left > 1) { int m = (left + right) / 2; PriorityQueue queue = new PriorityQueue<>(); for (int i = 0; i < m; i++) { queue.add(-t); } boolean flag = true; for (int i = n - 1; i >= 0; i--) { int x = queue.poll(); if (x + arr[i] > 0) { flag = false; break; } queue.add(x + arr[i]); } if (flag) { right = m; } else { left = m; } } System.out.print(right); } }