#include <bits/stdc++.h>
using namespace std;
int start[4050], last[4050], answer, dp[4050][4050];
int fdp(int i, int j) {
  if (dp[i][j]) return dp[i][j];
  if (i <= j) return 0;
  if (fdp(i - 1, j) >= start[i])
    dp[i][j] = dp[i - 1][j] + last[i];
  else
    dp[i][j] = start[i] + last[i] - 1;
  if (j && fdp(i - 1, j - 1) < dp[i][j]) dp[i][j] = dp[i - 1][j - 1];
  return dp[i][j];
}
int main() {
  int n, k, ans;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> start[i] >> last[i];
  ans = 86400 - fdp(n, k);
  for (int i = k; i < n; i++)
    if (start[i + 1] - fdp(i, k) > ans) ans = start[i + 1] - dp[i][k] - 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
