#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;
using std::vector;
int main() {
  const int DAY = 86400;
  int n, k;
  cin >> n >> k;
  vector<int> t(n), d(n);
  vector<int> f(n + 5, 0);
  for (int i = 0; i < n; ++i) {
    cin >> t[i] >> d[i];
    --t[i];
  }
  t.push_back(DAY);
  d.push_back(1);
  int ans = 0;
  for (int j = 0; j <= n; ++j) {
    ans = max(ans, t[j] - f[k]);
    for (int i = k; i > 0; --i) {
      f[i] = min(f[i - 1], max(f[i], t[j]) + d[j]);
      if (f[i] > DAY) f[i] = DAY;
    }
    f[0] = max(f[0], t[j]) + d[j];
    if (f[0] > DAY) f[0] = DAY;
  }
  cout << ans << endl;
  return 0;
}
