#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
int x,y;
bool operator<(const node &rhs) const{
return x<rhs.x;
}
};
node a[100005];
deque<int> q1;
deque<int>q2;
int n,D;
signed main()
{
cin>>n>>D;
for(int i=1;i<=n;i++)
{
cin>>a[i].x>>a[i].y;
}
sort(a+1,a+1+n);
int l=1,ans=1e18;
for(int i=1;i<=n;i++)
{
if(a[q1.back()].y-a[q2.back()].y>=D)
{
ans=min(i-l+1,ans);
}
while(1)
{
while(!q1.empty()&&q1.front()<=l)
{
q1.pop_front();
}
while(!q2.empty()&&q2.front()<=l)
{
q2.pop_front();
}
if(a[q1.back()].y-a[q2.back()].y<D)
{
break;
}
else{
l++;
ans=min(i-l+1,ans);
}
}
while(!q1.empty()&&a[q1.back()].y<=a[i].y)
{
q1.pop_back();
}
q1.push_back(i);
while(!q2.empty()&&a[q2.back()].y>=a[i].y)
{
q2.pop_back();
}
q2.push_back(i);
}
return 0;
}