#include <iostream>
using namespace std;
int matrix[2][101], ord[101], n, count = 1;
void sort() {
int finished = 0, size = n, swapped;
while(!finished) {
swapped = 0;
for(int i = 1; i < size; ++i) {
if(matrix[1][ord[i]] > matrix[1][ord[i+1]]) {
int temp = ord[i];
ord[i] = ord[i+1];
ord[i+1] = temp;
swapped = 1;
}
}
if(swapped) size--;
else finished = 1;
}
}
int main(int argc, char const *argv[]) {
int start,
end;
//freopen("spectacole.in", "r", stdin);
//freopen("spectacole.out", "w", stdout);
cin>>n;
for(int i = 1; i <= n; ++i) {
ord[i] = i;
cin>>start>>end;
matrix[ 0 ][ i ] = start;
matrix[ 1 ][ i ] = end;
}
sort();
int curr = matrix[1][ord[1]];
for(int i = 2; i <= n; ++i) {
if(matrix[0][ord[i]] >= curr) {
curr = matrix[ 1 ][ ord[ i ] ];
count++;
}
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYXRyaXhbMl1bMTAxXSwgb3JkWzEwMV0sIG4sIGNvdW50ID0gMTsKCnZvaWQgc29ydCgpIHsKICAgICBpbnQgZmluaXNoZWQgPSAwLCBzaXplID0gbiwgc3dhcHBlZDsKICAgICB3aGlsZSghZmluaXNoZWQpIHsKICAgICAgIHN3YXBwZWQgPSAwOwogICAgICAgZm9yKGludCBpID0gMTsgaSA8IHNpemU7ICsraSkgewogICAgICAgICBpZihtYXRyaXhbMV1bb3JkW2ldXSA+IG1hdHJpeFsxXVtvcmRbaSsxXV0pIHsKICAgICAgICAgICAgaW50IHRlbXAgPSBvcmRbaV07CiAgICAgICAgICAgIG9yZFtpXSA9IG9yZFtpKzFdOwogICAgICAgICAgICBvcmRbaSsxXSA9IHRlbXA7CiAgICAgICAgICAgIHN3YXBwZWQgPSAxOwogICAgICAgICB9CiAgICAgICB9CiAgICAgICBpZihzd2FwcGVkKSBzaXplLS07CiAgICAgICBlbHNlIGZpbmlzaGVkID0gMTsKICAgICB9Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0ICphcmd2W10pIHsKCiAgaW50IHN0YXJ0LAogICAgICBlbmQ7CgogIC8vZnJlb3Blbigic3BlY3RhY29sZS5pbiIsICJyIiwgc3RkaW4pOwoKICAvL2ZyZW9wZW4oInNwZWN0YWNvbGUub3V0IiwgInciLCBzdGRvdXQpOwoKICBjaW4+Pm47CgogIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgIG9yZFtpXSA9IGk7CiAgICAgIGNpbj4+c3RhcnQ+PmVuZDsKICAgICAgbWF0cml4WyAwIF1bIGkgXSA9IHN0YXJ0OwogICAgICBtYXRyaXhbIDEgXVsgaSBdID0gZW5kOwogIH0KCiAgc29ydCgpOwoKICBpbnQgY3VyciA9IG1hdHJpeFsxXVtvcmRbMV1dOwoKICBmb3IoaW50IGkgPSAyOyBpIDw9IG47ICsraSkgewoKICAgICAgaWYobWF0cml4WzBdW29yZFtpXV0gPj0gY3VycikgewoKICAgICAgICBjdXJyID0gbWF0cml4WyAxIF1bIG9yZFsgaSBdIF07CgogICAgICAgIGNvdW50Kys7CiAgICAgIH0KICB9CgogIGNvdXQ8PGNvdW50OwoKICByZXR1cm4gMDsKfQ==