#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int numRestaurants;
  long long int rappitTime;
  long long int maxJoy = numeric_limits<int>::min();
  long long int restJoy = 0;
  long long int lunchTime = 0;
  long long int ResJoy = 0;
  cin >> numRestaurants >> rappitTime;
  for (int i = 0; i < numRestaurants; ++i) {
    cin >> restJoy >> lunchTime;
    if (lunchTime > rappitTime)
      ResJoy = restJoy - (lunchTime - rappitTime);
    else
      ResJoy = restJoy;
    if (maxJoy < ResJoy) maxJoy = ResJoy;
  }
  cout << maxJoy << endl;
  return 0;
}
