#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int d = 0, c;
  if (k >= b[0]) {
    c = a[0];
  } else if (k < b[0]) {
    c = a[0] - (b[0] - k);
  }
  for (int i = 0; i < n; i++) {
    if (k >= b[i]) {
      d = a[i];
      if (c < d) {
        c = d;
      }
    } else {
      d = a[i] - (b[i] - k);
      if (c < d) {
        c = d;
      }
    }
  }
  cout << c << '\n';
  return 0;
}
