#include <bits/stdc++.h>
int N, K;
int DP[4001][4001];
int t[4001], d[4001];
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 ans = 0;
  scanf("%d%d", &N, &K);
  if (N == 0) ans = 86400;
  for (int i = 1; i <= N; i++) scanf("%d%d", &t[i], &d[i]);
  for (int i = 1; i <= N; i++) {
    DP[i][0] = max(t[i] - 1, DP[i - 1][0]) + d[i];
    for (int j = 1; j <= K; j++)
      DP[i][j] = min(max(t[i] - 1, DP[i - 1][j]) + d[i], DP[i - 1][j - 1]);
    for (int j = 0; j <= K; j++) {
      if (DP[i][j] > 86400) DP[i][j] = 86400;
      int tmp;
      if (i + K - j + 1 <= N)
        tmp = t[i + K - j + 1] - DP[i][j] - 1;
      else
        tmp = 86400 - DP[i][j];
      if (tmp > ans) ans = tmp;
    }
  }
  printf("%d\n", ans);
}
