#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int f, t;
  long int ans = -100000000000, j;
  while (n != 0) {
    cin >> f >> t;
    if (t > k)
      j = f - (t - k);
    else
      j = f;
    ans = max(ans, j);
    n--;
  }
  cout << ans;
}
