import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); int N,M; N = scan.nextInt(); M = scan.nextInt(); int[] C = new int[N]; int i, tmp, min, ans = 0; for (i = 0; i < N; i++) C[i] = scan.nextInt(); for (int j = 0; j < N; j++) { min = C[j]; for (i = N - 1; i > j; i--) { if (min > C[i]) { tmp = min; min = C[i]; C[i] = tmp; } } if (M >= min) { M -= min; ans++; if (M==0) break; } else { break; } } System.out.println(ans); } }