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