#include #include #include #include #include #include using namespace std; template constexpr T chmax(T& variable, const T value) noexcept { if (variable < value) return (variable = value); else return variable; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, H, i; cin >> N >> H; vector> stream_time(N); for (i = 0; i != N; ++i) cin >> stream_time[i].first >> stream_time[i].second; uint32_t ans = 0; priority_queue, greater> pq; pq.push(UINT32_MAX); for (i = 0; i != N; ++i) { while (pq.top() < stream_time[i].first) pq.pop(); pq.push(stream_time[i].second); chmax(ans, pq.size() - 1); } cout << ans << '\n'; return 0; }