#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;
const int MAXN = 4 * 1000 + 100;
const int MLOG = 17;
const int SQ = 400;
const int NMAX = 11;
int dp[MAXN][MAXN];
signed main() {
  ios_base ::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  pair<int, int> pr[MAXN];
  for (int i = 0; i < n; i++) {
    cin >> pr[i].first >> pr[i].second;
    pr[i].first--;
  }
  pr[n].first = 86400;
  sort(pr, pr + n);
  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i - 1][0], pr[i - 1].first) + pr[i - 1].second;
    for (int j = 1; j <= k; j++)
      dp[i][j] = min(max(dp[i - 1][j], pr[i - 1].first) + pr[i - 1].second,
                     dp[i - 1][j - 1]);
  }
  int ans = pr[0].first;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= k; j++) ans = max(ans, pr[i].first - dp[i][j]);
  cout << ans;
}
