#include <bits/stdc++.h>
using namespace std;
int n, k, f, t, large = pow(-10, 9);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  while (n--) {
    cin >> f >> t;
    if (t > k) f -= (t - k);
    if (f > large) large = f;
  }
  cout << large;
}
