// Arup Guha
// 2/2/2017
// Solution to 2017 January USACO Silver problem: Cow Dance

import java.util.*;
import java.io.*;

public class cowdance {

	public static int n;
	public static int maxT;
	public static int[] cows;

	public static void main(String[] args) throws Exception {

		// Read in input.
		BufferedReader stdin = new BufferedReader(new FileReader("cowdance.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		maxT = Integer.parseInt(tok.nextToken());
		cows = new int[n];
		for (int i=0; i<n; i++)
			cows[i] = Integer.parseInt(stdin.readLine());

		// Run a standard binary search.
		int low = 1 , high = n;
		while (low < high) {

			int mid = (low+high)/2;

			if (canDo(mid))
				high = mid;
			else
				low = mid+1;
		}

		// Here is our result, the larger of these two.
		PrintWriter out = new PrintWriter(new FileWriter("cowdance.out"));
		out.println(low);

		out.close();
		stdin.close();
	}

	// Returns true iff k cows will finish on time.
	public static boolean canDo(int k) {

		// Put in the first k cows into the priority queue.
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		for (int i=0; i<k; i++)
			pq.offer(cows[i]);

		// Now, place the rest of the cows in the Priority Queue - basically, get one
		// out and put in the finishing time of the next.
		for (int i=k; i<n; i++) {
			int curT = pq.poll();
			pq.offer(cows[i]+curT);
		}

		// Now, get everyone off the stage!
		int res = 0;
		while (pq.size() > 0)
			res = Math.max(res, pq.poll());

		// Here is whether we finished on time or not.
		return res <= maxT;
	}
}