#include <bits/stdc++.h>
using namespace std;
int n, k;
const int inf = (int)1e9;
int d[5000], t[5000], dp[4005][4005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &t[i], &d[i]);
  }
  t[n + 1] = 86401;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) dp[i][j] = inf;
  }
  dp[0][0] = 1;
  int res = t[k + 1] - 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      dp[i][j] = max(dp[i - 1][j], t[i]) + d[i];
      if (j > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
      res = max(res, t[min(n + 1, i + 1 + k - j)] - dp[i][j]);
    }
  }
  printf("%d", res);
  return 0;
}
