#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4 * 10 * 100 + 10, inf = 10e+8;
int dp[MAXN][MAXN];
pair<int, int> p[MAXN];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second, p[i].first--;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j] = inf;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++)
    dp[i][0] = max(dp[i - 1][0], p[i - 1].first) + p[i - 1].second;
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= k; j++)
      dp[i][j] = min(dp[i - 1][j - 1],
                     p[i - 1].second + max(p[i - 1].first, dp[i - 1][j]));
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) ans = max(ans, p[i - 1].first - dp[i - 1][j]);
  }
  ans = max(ans, 86400 - dp[n][k]);
  cout << ans;
  return 0;
}
