#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 4010;
int ti[maxn] = {};
int di[maxn] = {};
int dp[maxn][maxn] = {};
const int cinf = 1000000010;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d%d", &ti[i], &di[i]);
  for (int i = 0; i < maxn; ++i)
    for (int j = 0; j <= i; ++j) dp[i][j] = cinf;
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= i; ++j) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], max(dp[i][j], ti[i]) + di[i]);
    }
  int best = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j) {
      int rem = k - (i - j);
      if (rem < 0) continue;
      rem++;
      int tp = i + rem - 1;
      int to = 86400;
      if (tp < n) to = ti[tp] - 1;
      int fr = dp[i][j];
      best = max(best, to - fr + 1);
    }
  printf("%d\n", best);
  return 0;
}
