#include <iostream>
//#include <bits/stdc++.h>
#include <vector>
using namespace std;

int rastojanie(int a, int b) {
    return abs(a-b);
}

string levo_ili_desno(pair<int,int> platforma, pair<int,int> otsecka) {

    if(otsecka.first<platforma.first) {
        return "levo";
    }

    return "desno";


}
bool dali_moze(pair<int, int> otsecka, pair<int, int> platforma) {
    
    if(otsecka.first<platforma.first and otsecka.second>platforma.second) {
        return false;
    }
    if(otsecka.first>=platforma.first and otsecka.second<=platforma.second) {
        return true;
    }
    
    if(levo_ili_desno(platforma,otsecka)=="levo") {
            if(rastojanie(platforma.first,otsecka.second)>=rastojanie(platforma.first,otsecka.first)) {
                return true;
                
            }
        }
        else {
            if(rastojanie(otsecka.first,platforma.second)>=rastojanie(otsecka.second,platforma.second)) {
                return true;
                
            }
        }
    return false;

}
int main(){
    int N,L;
    pair<int,int> platforma;
    cin>>N>>L;
    vector<pair<int,int>> otsecka;
    platforma.first = 0;
    platforma.second = L;
   
    for(int i = 0; i<N; i++){
        int x,y;
        cin>>x>>y;
        otsecka.push_back(make_pair(x,y));
    }

    int brojac = 0;

    for(int i = 0; i<N; i++) {
        for(int j = 0; j < N; j++) {
            if(otsecka[j].first > -5000 and dali_moze(otsecka[j], platforma)) {
                brojac++;
                platforma.first = min(platforma.first, otsecka[j].first);
                platforma.second = max(platforma.second, otsecka[j].second);
                
                otsecka[j].first = -5000;
            }
        }
    }
    
    cout<<brojac;

}
