#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
void dbg(const char* fmt, ...) {}
const int size = 4096;
const int day = 86400;
int t[size];
int d[size];
int dp[size][size];
int main() {
  int n, k;
  int ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &t[i], &d[i]);
    t[i]--;
  }
  t[n++] = day;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= k; j++) dp[i][j] = day;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= k; j++) {
      ans = std::max(ans, t[i] - dp[i][j]);
      dp[i + 1][j + 1] = std::min(dp[i + 1][j + 1], dp[i][j]);
      dp[i + 1][j] = std::min(dp[i + 1][j], std::max(t[i], dp[i][j]) + d[i]);
    }
  printf("%d\n", ans);
  return 0;
}
