#include <bits/stdc++.h>
using namespace std;
const int nmax = 4009;
int f[nmax][nmax];
int t[nmax];
int d[nmax];
int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; ++i) {
    scanf("%d %d", &t[i], &d[i]);
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= K && j <= i; ++j) {
      ans = max(ans, t[i] - f[i - 1][j] - 1);
      f[i][j] = max(f[i - 1][j], t[i] - 1) + d[i];
      if (j > 0) {
        f[i][j] = min(f[i][j], f[i - 1][j - 1]);
      }
      if (i == N) {
        ans = max(ans, 86400 - f[i][j]);
      }
    }
  }
  ans = max(ans, 86400 - f[N][K]);
  printf("%d\n", ans);
  return 0;
}
