文件目录

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int a, b;
    bool operator<(const node &p) const
    {
        if (b == p.b)
            return a < p.a;
        return b < p.b;
    }
} p[10005];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i].a >> p[i].b;
    sort(p + 1, p + 1 + n);
    int ans = 1, k = p[1].b;
    for (int i = 2; i <= n; i++)
        if (p[i].a > k)
        {
            k = p[i].b;
            ans++;
        }
    cout << ans;
    return 0;
}