#include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
int C = 1;
cin >> N;
vector<int> S(N);
vector<int> E(N);
for(int i = 0; i < N; i++){
cin >> S[i] >> E[i];
}
for(int i = 1; i < N; i++){
if(S[i] >= E[i-1]){
C++;
}else{
E[i] = E[i-1];
}
}
cout << C;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKXsKICAgIGludCBOOwogICAgaW50IEMgPSAxOwogICAgY2luID4+IE47CiAgICB2ZWN0b3I8aW50PiBTKE4pOwogICAgdmVjdG9yPGludD4gRShOKTsKICAgIAogICAgZm9yKGludCBpID0gMDsgaSA8IE47IGkrKyl7CiAgICAgICAgY2luID4+IFNbaV0gPj4gRVtpXTsKICAgIH0KCiAgICBmb3IoaW50IGkgPSAxOyBpIDwgTjsgaSsrKXsKICAgICAgIGlmKFNbaV0gPj0gRVtpLTFdKXsKICAgICAgICBDKys7CiAgICAgICB9ZWxzZXsKICAgICAgICBFW2ldID0gRVtpLTFdOwogICAgICAgfQogICAgfQoKICAgIGNvdXQgPDwgQzsKICAgIAp9