import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); int[] array = new int[N]; for(int i = 0; i < N; i++){ array[i] = sc.nextInt(); } Arrays.sort(array); for(int i = 1; i < N; i++){ array[i] += array[i - 1]; } int pos = Arrays.binarySearch(array, M); if(pos < 0){ pos = -(pos + 1); }else{ pos++; } System.out.println(pos); } }