#include <bits/stdc++.h>
using namespace std;
int t[5000], d[5000], a[5000][5000];
int n, k;
int max(int a, int b) { return a > b ? a : b; }
void Solve() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &t[i], &d[i]);
  }
  memset(a, 0, sizeof(a));
  for (int i = 0; i <= n; ++i) a[i][i] = 1;
  int ans = t[k + 1] - 1;
  if (k == n) ans = 86400;
  for (int i = 1; i <= n; ++i) {
    a[i][0] = max(a[i - 1][0], t[i]) + d[i];
    for (int j = 1; j < i && j <= k; ++j) {
      a[i][j] = max(a[i - 1][j], t[i]) + d[i];
      if (a[i][j] > a[i - 1][j - 1]) a[i][j] = a[i - 1][j - 1];
    }
    for (int j = 0; j <= i && j <= k; ++j) {
      int end;
      if (i + k - j + 1 > n) {
        end = 86401;
      } else {
        end = t[i + k - j + 1];
      }
      if (end - a[i][j] > ans) ans = end - a[i][j];
    }
  }
  printf("%d\n", ans);
}
int main(int argc, char** argv) {
  Solve();
  return 0;
}
