#include #include #include #include using namespace std; typedef pair PII; typedef vector VP; typedef multiset> SI; int main() { int n,k; cin >> n >> k; VP shows(n); for (auto& x : shows) cin >> x.first >> x.second; sort(shows.begin(), shows.end(), [] (const PII& p, const PII& q) { return p.second < q.second; }); int ans=0; SI endtimes; for (const auto& x : shows) { auto it = endtimes.lower_bound(x.first); if (it!=endtimes.end()) endtimes.erase(it); if (endtimes.size()