#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4444;
int n, k;
int t[MAXN], d[MAXN];
int f[MAXN][MAXN];
void Init() {
  assert(scanf("%d%d", &n, &k) == 2);
  for (int i = 1; i <= n; ++i) {
    assert(scanf("%d%d", t + i, d + i) == 2);
  }
  t[n + 1] = 86401;
}
void Work() {
  int ans = t[k + 1] - 1;
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i][0] = max(f[i - 1][0], t[i]) + d[i];
    if (i + k <= n) {
      ans = max(ans, t[i + k + 1] - f[i][0]);
    } else {
      ans = max(ans, t[n + 1] - f[i][0]);
    }
    for (int j = 1; j <= min(i, k); ++j) {
      f[i][j] = f[i - 1][j - 1];
      if (j < i) f[i][j] = min(f[i][j], max(f[i - 1][j], t[i]) + d[i]);
      int edt;
      if (i + (k - j) <= n) {
        edt = t[i + (k - j) + 1];
      } else {
        edt = t[n + 1];
      }
      ans = max(ans, edt - f[i][j]);
    }
  }
  printf("%d\n", ans);
}
int main() {
  Init();
  Work();
  return 0;
}
