#include <bits/stdc++.h>
using namespace std;
inline void wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
template <class T>
inline T fastIn() {
  register char c = 0;
  register T a = 0;
  bool neg = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-') {
      neg = true;
    } else {
      a = (a * 10) + (c - '0');
    }
    c = getchar();
  }
  return neg ? -a : a;
}
int const mxn = (int)1e4 + 5;
int rabitCount, totalTime;
int fi[mxn];
int ti[mxn];
inline void read() {
  rabitCount = fastIn<int>(), totalTime = fastIn<int>();
  for (int i = (0), _i = (rabitCount); (i) < (_i); ++i) {
    fi[i] = fastIn<int>(), ti[i] = fastIn<int>();
  }
}
const int inf = 1023456789;
inline void proc() {
  int bst = -inf;
  for (int i = (0), _i = (rabitCount); (i) < (_i); ++i) {
    int funValue = fi[i];
    if (ti[i] > totalTime) {
      funValue -= (ti[i] - totalTime);
    }
    bst = max(bst, funValue);
  }
  cout << bst << "\n";
}
int main() {
  int kase = 1;
  for (int i = (0), _i = (kase); (i) < (_i); ++i) {
    read();
    proc();
  }
  return 0;
}
