#include <bits/stdc++.h>
using namespace std;
void dbg(int x) { cout << "x is " << x << "\n"; }
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int mx = -1e18;
  while (n--) {
    long long int t, f;
    cin >> f >> t;
    if (t > k) {
      mx = max(mx, f - t + k);
    } else {
      mx = max(mx, f);
    }
  }
  cout << mx;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
