#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
int N,K;
int cnt=0;
vector<int> vec;
vector<int> vt;
map<int,int> mp;
int maxN=2000;
int a[2005],b[2005];
set<int> s;
int main ()
{
	cin>>N>>K;
	for(int i=1;i<maxN;i++)
	{	
		cin>>a[i]>>b[i];
		mp[(long long)b[i]]=a[i];
		s.insert(mp[b[i]]);cnt++;
		cnt.push_back(vec);
	}
	sort(vec.begin(),vec.end());
	int q=vec.max;
	if(q>K) cout<<q-K;
	else cout<<0
	return 0;
}