import java.util.Scanner; import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(new BufferedInputStream(System.in)); int n = sc.nextInt(); int l = sc.nextInt(); int[][] arr = new int[n][2]; for(int i=0;i<n;i++){ arr[i][0] = sc.nextInt(); arr[i][1] = sc.nextInt(); } Arrays.sort(arr,new Comparator<int[]>() { public int compare(int[] o1, int[] o2) { return o1[0]==o2[0]?o1[1]-o2[1]:o1[0]-o2[0]; } }); int right = 0; // 当前覆盖边界 int res= 0; for(int i=0;i<n;){ //左 够到门槛 if(arr[i][0] <= right ){ int max = 0; while(i<n && arr[i][0]<=right){ max = Math.max(max,arr[i][1]); i++; } right = max; res++; if(right>=l) { System.out.println(res); return; } }else{ System.out.println(-1); return; } } System.out.println(-1); } }