#include <iostream>
#include <vector>
using namespace std;

bool dali_ke_se_zalepi(int platforma_L, int platforma_R, int otsecka_L, int otsecka_R) {
    
    if(otsecka_R < platforma_L or platforma_R < otsecka_L) {
        return false;
    }
    if(otsecka_L < platforma_L and platforma_R < otsecka_R) {
        return false;
    }
    
    if(platforma_L <= otsecka_L and otsecka_R <= platforma_R) {
        return true;
    }
    if(otsecka_L < platforma_L) {
        if(otsecka_R - platforma_L >= platforma_L - otsecka_L) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        if(platforma_R - otsecka_L >= otsecka_R - platforma_R) {
            return true;
        }
        else {
            return false;
        }
    }
    
    return false;
}
int main()
{
    int n, L;
    cin >> n >> L;
    
    vector<pair<int, int> > otsecki;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        otsecki.push_back(make_pair(a, b));
    }
    int platforma_L = 0, platforma_R = L;
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(dali_ke_se_zalepi(platforma_L, platforma_R, otsecki[i].first, otsecki[i].second)) {
            cnt++;
            platforma_L = min(platforma_L, otsecki[i].first);
            platforma_R = max(platforma_R, otsecki[i].second);
        }
    }
    cout << cnt << endl;
    return 0;
}
