#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10 + 7;
const long long mod = 1e9 + 7;
template <class T>
void read(T &val) {
  cin >> val;
}
template <class T>
void read(vector<T> &a, long long n, long long g = 0) {
  for (long long i = g; i < n + g; i++) cin >> a[i];
}
template <class T>
void pv(vector<T> &a) {
  for (auto i : a) cout << i << " ";
  cout << "\n";
}
void solver() {
  long long n, t;
  cin >> n >> t;
  long long ans = -inf;
  for (long long i = 0; i < n; i++) {
    long long c, d;
    cin >> c >> d;
    if (d < t) {
      ans = max(ans, c);
    } else {
      ans = max(ans, c - (d - t));
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(15);
  long long t = 1;
  while (t--) {
    solver();
  }
}
