#include <iostream>
#include <cmath>
using namespace std;
typedef long long shuju;
struct zuobiao
{
shuju x;
shuju y;
};
int main()
{
shuju n=0;
shuju k=0;
shuju tag=0;
cin>>n>>k;
zuobiao a[510];
shuju X=0;
shuju Y=0;
for(shuju i=0;i<n;i++)
{
cin>>a[i].x>>a[i].y;
if(X<a[i].x)
{
X=a[i].x;
}
if(Y<a[i].y)
{
Y=a[i].y;
}
}
for(shuju j=0;j<n;j++)
{
shuju yes=0;
shuju no=0;
shuju t=-1;
for(shuju p=0;p<n;p++)
{
if(a[p].y==a[j].y)
{
yes++;
if(t==-1)
{
t=p;
}
else
{
no+=a[p].y-a[t].y;
t=p;
}
}
}
if(tag<yes+k&&no<=k)
{
tag=yes+k;
}
}
for(shuju j=0;j<n;j++)
{
shuju yes=0;
shuju no=0;
shuju t=-1;
for(shuju p=0;p<n;p++)
{
if(a[p].x==a[j].x)
{
yes++;
if(t==-1)
{
t=p;
}
else
{
no+=a[p].x-a[t].x;
t=p;
}
}
}
if(tag<yes+k&&no<=k)
{
tag=yes+k;
}
}
cout<<tag<<endl;
return 0;
}