活动安排
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 1010;
int n;
PII q[N];
int main()
{
cin >> n;
for(int i = 0; i < n; i ++)
cin >> q[i].y >> q[i].x;
sort(q, q + n);
int cnt = 0, end = -1;
for(int i = 0; i < n; i ++)
{
if(end <= q[i].y)
{
cnt ++;
end = q[i].x;
}
}
cout << cnt;
return 0;
}