package yukicoder; import java.util.Arrays; import java.util.Scanner; public class Yuki156 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int candyBox[] = new int[n]; for (int i = 0; i < n; i++) { candyBox[i] = scan.nextInt(); } Arrays.sort(candyBox); scan.close(); int boxCount = 0; for (int i = 0; i < n; i++) { m -=candyBox[i]; if (m >= 0) { boxCount++; } } System.out.println(boxCount); } }