import java.io.*; import java.util.*; import java.math.*; class Main156 { public static void out (Object out) { System.out.println(out); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split(" "); String[] line2 = br.readLine().split(" "); int ans = 0, sum = 0; int n = Integer.parseInt(line1[0]); int m = Integer.parseInt(line1[1]); int[] nums = new int[n]; for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(line2[i]); Arrays.sort(nums); for (int i = 0; i < n; i++) { sum += nums[i]; if (sum <= m) { ans++; } else { break; } } out(ans); } }