#include <bits/stdc++.h>
using namespace std;
int main() {
  int qnt, time, felicity, time_to_eat, best = -999999999;
  cin >> qnt >> time;
  for (int i = 0; i < qnt; i++) {
    cin >> felicity >> time_to_eat;
    if (time_to_eat <= time && felicity > best) {
      best = felicity;
    } else if (time_to_eat > time) {
      int aux = felicity - (time_to_eat - time);
      if (aux > best) {
        best = felicity - (time_to_eat - time);
      }
    }
  }
  cout << best << endl;
  return 0;
}
