import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.stream.Stream; public class No00000156_Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] mArr = br.readLine().split(" "); int n = Integer.parseInt(mArr[0]); int m = Integer.parseInt(mArr[1]); int[] cArr = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); Arrays.sort(cArr);; int cnt = 0; for(int i = 0; i < n; i++) { if(m >= cArr[i]) { cnt++; m -= cArr[i]; } } System.out.println(cnt); } }