#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  int b;
  int c = -1000000000;
  cin >> a >> b;
  for (int z = 0; a > z; z++) {
    int x;
    int y;
    cin >> x >> y;
    int w = x;
    if (y > b) {
      w -= (y - b);
    }
    if (w > c) {
      c = w;
    }
  }
  cout << c;
  return 0;
}
