const lines = require('fs') .readFileSync('/dev/stdin', 'utf-8') .trim().split('\n').values(); let [N, M] = lines.next().value.split(' ').map(x => Number(x)); let C = lines.next().value.split(' ').map(x => Number(x)); ans = 0; C.sort((a, b) => a - b); for (let i = 0; i < N; i++) { if (C[i] <= M) { M -= C[i]; ans++; } else { break; } } console.log(ans);