#include <bits/stdc++.h>
using namespace std;
int n, k;
int t[4005], d[4005];
int f[4005][4005], g[4005][4005], p[4005][4005];
void Gao() {
  int i, j, tf, tp, tg, cnt, ans;
  memset(f, 0xff, sizeof f);
  memset(g, 0x3f, sizeof g);
  memset(p, 0x3f, sizeof p);
  f[0][0] = 0;
  g[0][0] = 1;
  p[0][0] = 1;
  for (i = 1; i <= n; ++i) {
    for (j = 0; j <= k; ++j) {
      tg = -1;
      if (f[i - 1][j] != -1) {
        f[i][j] = f[i - 1][j];
        cnt = t[i] - g[i - 1][j];
        if (cnt < 0) cnt = 0;
        if (f[i][j] < cnt) f[i][j] = cnt;
        if (t[i] > g[i - 1][j])
          tg = t[i] + d[i];
        else
          tg = g[i - 1][j] + d[i];
      }
      if (tg != -1) {
        g[i][j] = tg;
      }
      if (j == 0) continue;
      if (f[i - 1][j - 1] != -1) {
        tf = f[i - 1][j - 1];
        if (f[i][j] < tf) {
          f[i][j] = tf;
        }
        if (tg == -1)
          g[i][j] = g[i - 1][j - 1];
        else if (g[i][j] > g[i - 1][j - 1])
          g[i][j] = g[i - 1][j - 1];
        p[i][j] = g[i][j];
      }
    }
  }
  ans = 0;
  for (i = 0; i <= k; ++i) {
    if (ans < f[n][i]) ans = f[n][i];
    if (g[n][i] < 86401) {
      cnt = 86401 - g[n][i];
      if (ans < cnt) ans = cnt;
    }
  }
  printf("%d\n", ans);
}
int main() {
  int i;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; ++i) scanf("%d %d", &t[i], &d[i]);
  Gao();
  return 0;
}
