#include<bits/stdc++.h> #define ll long long #define INF 1e9 usingnamespace std; int n, d, ans; structxvl_ { int l, r; booloperator < (const xvl_& s) const { return r < s.r; } }a[200005]; signedmain(){ ios :: sync_with_stdio(0); cin >> n >> d; for (int i = 1; i <= n; i++) cin >> a[i].l >> a[i].r; sort(a + 1, a + 1 + n); for (int i = 1; i <= n; ans++) { int bk = i + 1; while (a[bk].l <= a[i].r + d - 1and bk <= n) bk++; i = bk; // 前面的墙被打破了 } cout << ans; return0; }