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