// Arup Guha
// 11/9/2025
// Alternate Solution to 2025 SER D1 Problem F: Meeting Free Fridays
// My old solution used RMQ, which wasn't necessary due to the order
// and structure of the minimums I needed. This solution just updates
// the minimums as needed, only looping through unseen values, making
// the overall run time O(n^2), an improvement over my old O(n^2lgn) code.

import java.util.*;

public class meetingfreefridays_alt {

	public static int n;
	public static int nap;
	public static int dayT;
	public static mtg[] list;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		dayT = stdin.nextInt();
		nap = stdin.nextInt();
		list = new mtg[n];
		
		// Read in meetings.
		for (int i=0; i<n; i++) {
			int s = stdin.nextInt();
			int e = stdin.nextInt();
			list[i] = new mtg(s, e, i);
		}
		
		// Sort for DP.
		Arrays.sort(list);
		
		// if lookback[i] = x, then event x is the last event we can do before we start event i.
		int[] lookback = new int[n];
		lookback[0] = -1;
		for (int i=1; i<n; i++) {
			int j = i-1;
			while (j>=0 && list[j].e > list[i].s) j--;
			lookback[i] = j;
		}
		
		// This is min time used for one event ending with event i.
		boolean canDo = false;
		int[] dp = new int[n];
		for (int i=0; i<n; i++) {
			dp[i] = list[i].t;
			if (dp[i] <= dayT-nap)
				canDo = true;
		}
		
		// Get this out of the way.
		if (!canDo) {
			System.out.println(0);
			return;
		}
		
		// Now I can start here.
		int res = 1;
		
		// m is the number of meetings we are trying to run.
		for (int m=2; m<=n; m++) {
		
			// Will store DP for m meetings building off of m-1 meetings.
			// dayT+1 means can't do it.
			int[] next = new int[n];
			Arrays.fill(next, dayT+1);
			
			boolean ok = false;
			
			int start = 0, runMin = dayT+1;
			
			// No point starting any earlier.
			for (int j=m-1; j<n; j++) {
			
				// Nothing to build off of.
				if (lookback[j] < 0) continue;
				
				for (int k=start; k<=lookback[j]; k++)
					runMin = Math.min(runMin, dp[k]);
				
				// Update where we start next time so our total run time of the k loop is O(n).
				start = lookback[j];
				
				// Also not valid.
				if (runMin >= dayT) continue;
				
				// Time for this event.
				next[j] = runMin + list[j].t;
				
				// Means we've found something that works.
				if (next[j] <= dayT-nap)
					ok = true;
			}
			
			// Couldn't do it.
			if (!ok) break;
			
			// We were able to do this.
			res = m;
			
			// Update previous dp array.
			dp = next;
		}
		
		System.out.println(res);
	}
}

class mtg implements Comparable <mtg> {

	public int s;
	public int e;
	public int t;
	public int ID;
	
	public mtg(int mys, int mye, int mid) {
		s = mys;
		e = mye;
		t = e - s;
		ID = mid;
	}
	
	public int compareTo(mtg other) {
		if (this.e != other.e)
			return this.e - other.e;
		if (this.s != other.s)
			return other.s - this.s;
		return this.ID - other.ID;
	}
}