#include <bits/stdc++.h>
using namespace std;
int n, k;
int s[4005], e[4005];
int dp[4005][4005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &s[i], &e[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i && j <= k; j++) {
      dp[i][j] = max(dp[i - 1][j], s[i] - 1) + e[i];
      if (j) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
    }
  }
  int ans = s[1] - 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i - 1 && j <= k; j++) {
      ans = max(ans, s[i] - dp[i - 1][j] - 1);
    }
  }
  for (int i = 0; i <= k; i++) ans = max(ans, 86400 - dp[n][i]);
  printf("%d\n", ans);
}
