#include <bits/stdc++.h>
using namespace std;
int n, k;
struct call {
  int t, d;
} c[4005];
int a[4005][4005];
int main(int argc, char** argv) {
  scanf("%d%d", &n, &k);
  if (n == k) {
    printf("86400\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) scanf("%d%d", &c[i].t, &c[i].d);
  int ans = 0;
  a[1][1] = a[0][0] = 1;
  a[1][0] = c[1].t + c[1].d;
  for (int i = 2; i <= n; ++i) {
    if (a[i - 1][0] > c[i].t)
      a[i][0] = a[i - 1][0] + c[i].d;
    else
      a[i][0] = c[i].t + c[i].d;
    a[i][0] = min(86401, a[i][0]);
    a[i][i] = 1;
  }
  for (int i = 2; i <= n; ++i) {
    int limit = min(i, k);
    for (int j = 1; j <= limit; ++j) {
      int t = (a[i - 1][j] > c[i].t) ? a[i - 1][j] + c[i].d : c[i].t + c[i].d;
      a[i][j] = min(a[i - 1][j - 1], t);
    }
  }
  for (int i = 1; i <= n; ++i) {
    int limit = min(i, k);
    for (int j = 0; j <= limit; ++j) {
      if (i + 1 + k - j > n)
        ans = max(ans, 86401 - a[i][j]);
      else
        ans = max(ans, c[i + 1 + k - j].t - a[i][j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
