// let L, N, W; // process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', data => { const arr = data.split('\n'); L = Number(arr[0]); N = Number(arr[1]); W = arr[2].split(' ').map(x => Number(x)).sort(); }); process.stdin.on('end', () => { let count = 0, sum = 0; while (L - sum <= W[count]) { sum += W[count]; count++; } console.log(count); });