#include <bits/stdc++.h>
using namespace std;
int n, k, resp;
int t[4003], d[4003];
int pd[4003][4003];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d %d", t + i, d + i);
  memset(pd, 63, sizeof pd);
  t[++n] = 86401, pd[0][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0, lim = min(i - 1, k); j <= lim; ++j) {
      resp = max(resp, t[i] - pd[i - 1][j]);
      pd[i][j] = min(pd[i][j], max(t[i], pd[i - 1][j]) + d[i]);
      if (j < k) pd[i][j + 1] = pd[i - 1][j];
    }
  printf("%d\n", resp);
  return 0;
}
