#include <stdio.h>
#include <stdlib.h>
int cmp(const void* a, const void* b) {
return *(int*)a - *(int*)b;
}
int computeGroupCount(int w, int n, int* prices) {
qsort(prices, n, sizeof(int), cmp);
int left = 0;
int right = n - 1;
int count = 0;
while (left <= right) {
if (prices[left] + prices[right] <= w) {
left++;
right--;
count++;
}
else {
right--;
count++;
}
}
return count;
}
int main() {
int w;
scanf("%d", &w);
int n;
scanf("%d", &n);
int* prices = (int*)malloc(n * sizeof(int));
for (int i = 0; i < n; i++) {
scanf("%d", &prices[i]);
}
int groupCount = computeGroupCount(w, n, prices);
printf("%d\n", groupCount);
free(prices);
return 0;
}