#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t, f, mx = -1000000000;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> f >> t;
    if (t > k) f -= (t - k);
    mx = max(mx, f);
  }
  cout << mx;
  return 0;
}
