#include <bits/stdc++.h>
using namespace std;
void solution() {
  int n, k;
  cin >> n >> k;
  int max_ = INT_MIN;
  int ans;
  while (n--) {
    int a, b;
    cin >> a >> b;
    if (b >= k) {
      ans = a - (b - k);
    } else {
      ans = a;
    }
    max_ = max(max_, ans);
  }
  cout << max_ << endl;
}
int32_t main() {
  solution();
  return 0;
}
