#include <bits/stdc++.h>
using namespace std;
int b, t, d[5000], n, k, e, i, j;
int main() {
  cin >> n >> k;
  d[0] = 1;
  for (i = 0; i <= n; i++) {
    if (i < n)
      cin >> b >> t;
    else
      b = 86401, t = 1;
    for (j = min(k, i + 1); j >= 0; --j) {
      e = max(e, b - d[j]);
      d[j] = min(j == 0 ? (1 << 30) : d[j - 1], max(d[j], b) + t);
    }
  }
  cout << e;
}
