import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); int []C = new int[N]; for(int i = 0; i < N; i++) { C[i] = scan.nextInt(); } scan.close(); Arrays.sort(C); int ans = 0; for(int i = 0; i < N; i++) { M -= C[i]; ans ++; if(M == 0) { System.out.println(ans); System.exit(0); }else if(M <= 0) { System.out.println(ans - 1); System.exit(0); } } System.out.println(ans); } }