// Movie Festival #include using namespace std; using ll = long long; int main() { int n; cin >> n; vector> movies(n); for (auto &p: movies) { ll a, b; cin >> a >> b; p = {b, a}; } int count = 0; int current_time = 0; std::sort(movies.begin(), movies.end()); for (auto &[end, start]: movies) { if (start >= current_time) { current_time = end; count++; } } cout << count << endl; return 0; }