#include
#include
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 > 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;
vector iskoristeno(n, false);
int cnt = 0;
cout << endl;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(!iskoristeno[j]) {
if(dali_ke_se_zalepi(platforma_L, platforma_R, otsecki[j].first, otsecki[j].second)) {
iskoristeno[j] = true;
platforma_L = min(platforma_L, otsecki[j].first);
platforma_R = max(platforma_R, otsecki[j].second);
cnt++;
}
}
}
}
cout << cnt << endl;
return 0;
}