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