#include<bits/stdc++.h>
using namespace std;
struct s{
int a,b;
bool bl = 1;
}bs[1000010];
bool cmp(s x,s y)
{
return x.a < y.a;
}
int main()
{
int n;
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> bs[i].a >> bs[i].b;
}
sort(bs + 1,bs + n + 1,cmp);
int sum = 0;
for (int i = 1;i <= n;i++)
{
if (bs[i].bl) {
for (int j = i + 1;j <= n;j++) {
if (bs[j].a <bs[i].b) bs[j].bl = 0;
}
sum++;
}
}
cout << sum;
return 0;
}