// Arup Guha
// 11/9/2025
// Solution to 2025 SER D1 Problem F: Meeting Free Fridays

import java.util.*;

public class meetingfreefridays {

	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;
		
		// I'll need this to build my DP.
		rmq mine = new rmq(dp, dayT+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;
			
			// No point starting any earlier.
			for (int j=m-1; j<n; j++) {
			
				// Nothing to build off of.
				if (lookback[j] < 0) continue;
				
				// Best answer previously.
				int prev = mine.query(lookback[j]);
				
				// Also not valid.
				if (prev >= dayT) continue;
				
				// Time for this event.
				next[j] = prev + 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 RMQ.
			mine = new rmq(next, dayT+1);
		}
		
		System.out.println(res);
	}
	
	public static void print(int[] a) {
		for (int i=0; i<a.length; i++)
			System.out.print(a[i]+" ");
		System.out.println();
	}
}

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;
	}
}

class rmq {

	public int n;
	public int[][] arr;
	public int mymax;
	
	public rmq(int[] vals, int safeMax) {
	
		mymax = safeMax;
	
		// Set up length. I am using indexes 1 to (1<<b).
		int b = 1;
		while ((1<<b) < vals.length+1) b++;
		n = (1<<b);
		
		arr = new int[b][];
		for (int i=0; i<b; i++) {
			arr[i] = new int[ (1<<(b-i)) ];
			Arrays.fill(arr[i], safeMax);
		}
		
		// Copy in base values.
		for (int i=0; i<vals.length; i++)
			arr[0][i] = vals[i];
			
		for (int i=1; i<b; i++) 
			for (int j=0; j<arr[i].length; j++)
				arr[i][j] = Math.min(arr[i-1][2*j], arr[i-1][2*j+1]);
	}
	
	public int query(int maxI) {
		
		int tmpI = maxI+1;
		int lsb = 0;
		int res = mymax;
		
		while (tmpI > 0) {
			
			while ((tmpI & (1<<lsb)) == 0) lsb++;
			
			// Index for query.
			int idx = (tmpI-1)/(1<<lsb);
			res = Math.min(res, arr[lsb][idx]);
			tmpI -= (1<<lsb);
		}
		
		return res;
	}
}