#include <bits/stdc++.h>
using namespace std;
int a, b, c, man, j, mix, x, y, z, ans, ans1, ans2, ans3, l, r, d[500000];
vector<int> v, v1;
string s, s1, s2;
map<int, int> mp, mp1;
bool o, bo;
long double ld;
pair<long long, long long> p[1000000];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  mix = -10000000000;
  for (int i = 0; i < a; i++) {
    cin >> c >> x;
    if (x > b) {
      mix = max(mix, c - x + b);
    } else
      mix = max(mix, c);
  }
  cout << mix;
}
