#include <bits/stdc++.h>
using namespace std;
struct seg {
int start, end;
seg() { start = end = 0; }
seg(int s, int e) { start = s, end = e; }
bool covers(seg& other) { return other.start < start && start < other.end || other.start < end && end < other.end; }
};
int fun(istream& ins) {
int n;
ins >> n;
seg competitions[n];
vector<seg> added;
for (int i = 0; i < n; i++) {
ins >> competitions[i].start >> competitions[i].end;
}
for (int i = 0; i < n; i++) {
bool tmp = true;
for (int j = 0; j < added.size(); j++)
if (competitions[i].covers(added[j])) {
tmp = false;
break;
}
if (tmp) {
added.push_back(competitions[i]);
}
}
return added.size();
}
#define ensure(func, input, output) \
{ \
std::stringstream in(input); \
assert(func(in) == output); \
}
void test() {
ensure(fun, "3\n0 2\n2 4\n1 3\n", 2);
ensure(fun, "4\n0 5\n2 3\n4 9\n5 7\n", 2);
ensure(fun, "3\n0 5\n4 8\n5 10\n", 2);
ensure(fun, "6\n0 3\n2 6\n3 4\n5 8\n4 5\n2 7\n", 4);
cout << "All pass!" << endl;
}
int main() {
cout << fun(cin);
return 0;
}