package P156; import java.io.*; import java.util.Arrays; import java.util.Scanner; public class P156 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String k = sc.nextLine(); String[] kstrs = k.split(" "); int N = Integer.parseInt(kstrs[0]); int M = Integer.parseInt(kstrs[1]); String l = sc.nextLine(); String[] lstrs = l.split(" "); int C[] = new int[N]; int i = 0; int sum = 0; for (i=0;i<=N-1;i++) { C[i] = Integer.parseInt(lstrs[i]); sum = sum + C[i]; } if (M >= sum){ i = N; M = 0; } else { Arrays.sort(C); i = 0; while (M > 0) { if (C[i] < M) { M = M - C[i]; i++; } else { M = 0; } } } System.out.println(i); } }