#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4005;
int dp[MAXN][MAXN];
int N, K;
struct phone {
  int st, t;
} P[MAXN];
int ans;
void DP() {
  ans = 0;
  dp[0][0] = 0;
  for (int i = 1; i <= N; ++i) {
    if (P[i].st <= dp[i - 1][0]) {
      dp[i][0] = dp[i - 1][0] + P[i].t;
    } else {
      ans = max(ans, P[i].st - dp[i - 1][0] - 1);
      dp[i][0] = P[i].st + P[i].t - 1;
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= min(i, K); ++j) {
      if (P[i].st <= dp[i - 1][j]) {
        dp[i][j] = dp[i - 1][j] + P[i].t;
      } else {
        dp[i][j] = P[i].st + P[i].t - 1;
        ans = max(ans, P[i].st - dp[i - 1][j] - 1);
      }
      dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
    }
  }
  ans = max(86400 - dp[N][K], ans);
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) {
    scanf("%d%d", &P[i].st, &P[i].t);
  }
  DP();
}
