#include <stdio.h>
#include <stdlib.h>

int int_sort(const void* a, const void* b ) {
  if(*(int*)a > *( int*)b ) {
    return -1;
  }
  else
  if(*(int*)a == *(int*)b) {
    return 0;
  }
  return 1;
}

int main(void) {
	int i, n, m, c[20] = {0}, cou = 0;
	
	scanf("%d %d", &n, &m);
	for(i = 0; m > i; i++){
		scanf("%d", &c[i]);
	}
	
	qsort((void*)c, m, sizeof(c[0]), int_sort);
	i = 0;
	while(n > 0){
		if(n < c[i]){
			i++;
		}
		n -= c[i];
		cou++;
	}
	printf("%d\n", cou);
	return 0;
}