#include using namespace std; int main() { int box_long; int block_num; int block_width[10000]; cin >> box_long >> block_num; for(int i = 0; i < block_num; ++i) { cin >> block_width[i]; } for(int i = 0; i < block_num - 1; ++i) { for(int j = block_num - 1; j >= i; --j) { if(block_width[j - 1] > block_width[j]) { int temp = block_width[j - 1]; block_width[j - 1] = block_width[j]; block_width[j] = temp; } } } int i; for(i = 0; (box_long -= block_width[i]) >= 0; ++i); cout << i << endl; return 0; }