#include using namespace std; using ll = long long; using P = pair; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; int main(void) { ll n; cin >> n; vector

r(n); rep(i, 0, n) { cin >> r[i].first >> r[i].second; } ranges::sort(r); ranges::reverse(r); ll ans = n; ll cur = inf; rep(i, 0, n) { if(r[i].second <= cur) { ans--; cur = r[i].first; } } cout << ans << '\n'; }