import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int n = sc.nextInt(); int m = sc.nextInt(); List list = new ArrayList<>(); for (int i = 0;i < n;i++) { list.add(sc.nextInt()); } Collections.sort(list); int ret = 0; for (int i = 0;i < n;i++) { int num = list.get(i); if (num <= m) { ret++; m -= num; } else { break; } } System.out.println(ret); } }