#include <bits/stdc++.h>
using namespace std;
pair<int, int> t[5000];
int n, k, ans, dp[5000][5000], g[5000];
void Init() {
  cin >> n >> k;
  t[0].first = 1, t[0].second = 0;
  for (int i = 1; i <= n; i++) cin >> t[i].first >> t[i].second;
  t[++n].first = 86401, t[n].second = 0;
  sort(t, t + n);
}
void Solve() {
  g[0] = 1, dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (dp[i - 1][0] <= t[i].first)
      dp[i][0] = t[i].first + t[i].second;
    else
      dp[i][0] = dp[i - 1][0] + t[i].second;
    ans = max(t[i].first - dp[i - 1][0], ans);
    g[i] = dp[i][0];
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= min(i - 1, k); j++) {
      int s = i - j - 1;
      if (g[s] <= t[i].first)
        dp[i][j] = t[i].first + t[i].second;
      else
        dp[i][j] = g[s] + t[i].second;
      ans = max(t[i].first - g[s], ans);
      g[i - j] = min(g[i - j], dp[i][j]);
    }
  cout << ans << endl;
}
int main() {
  Init();
  Solve();
  return 0;
}
