import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static void main(String[] args) { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); try { String[] box = read.readLine().split(" "); int[] num = new int[2]; for (int i = 0; i < 2; ++i) { num[i] = Integer.parseInt(box[i]); } box = read.readLine().split(" "); ArrayList array = new ArrayList<>(num[0]); for (int i = 0; i < num[0]; ++i) { array.add(Integer.parseInt(box[i])); } array.sort(null); int ans = 0; for (int i = 0; i < num[0]; ++i) { if (num[1] - array.get(i) >= 0) { num[1] -= array.get(i); ans++; } else { break; } } System.out.println(ans); } catch (Exception e) { e.printStackTrace(); } } }