#include <bits/stdc++.h>
const int N = 4010;
int t[N], d[N];
int DP[N][N];
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
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 = t[k + 1] - 1;
  if (n == k) ans = 86400;
  t[n + 1] = 86401;
  DP[1][1] = 1;
  DP[1][0] = t[1] + d[1];
  ans = max(ans, t[2] - DP[1][0]);
  for (int i = 2; i <= n; i++)
    for (int j = 0; j <= k && j <= i; j++) {
      if (j == 0)
        DP[i][j] = max(DP[i - 1][0], t[i]) + d[i];
      else
        DP[i][j] = min(max(DP[i - 1][j], t[i]) + d[i], DP[i - 1][j - 1]);
      ans = max(ans, t[i + 1] - DP[i][j]);
    }
  printf("%d\n", ans);
  scanf(" ");
}
