let lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n"); let buf = lines[0].split(" "); let placeNum = parseInt(buf[0]); let jyosoluzaiNum = parseInt(buf[1]); let placeList = []; for(let place of lines[1].split(" ")){ placeList.push(parseInt(place)); } placeList.sort((a,b) => a-b); let count = 0; for(let place of placeList){ if(place <= jyosoluzaiNum){ count++; jyosoluzaiNum -= place; } else { break; } } console.log(count + " " + jyosoluzaiNum);