#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int f, t;
  int maxi = -1e9;
  while (n) {
    cin >> f >> t;
    if (t > k)
      maxi = max(maxi, f - (t - k));
    else
      maxi = max(maxi, f);
    n--;
  }
  cout << maxi;
}
