#include <bits/stdc++.h>
using namespace std;
int dp[4010][4010];
int main() {
  int n, k;
  cin >> n >> k;
  pair<int, int> s[4010];
  for (int i = 0; i < n; i++) cin >> s[i].first >> s[i].second;
  memset(dp, 0x7f, sizeof dp);
  dp[0][1] = 1;
  dp[0][0] = s[0].first + s[0].second;
  for (int i = 1; i < n; i++) {
    for (int u = 0; u <= k; u++) {
      dp[i][u + 1] = dp[i - 1][u];
    }
    for (int u = 0; u <= k; u++) {
      int pos = dp[i - 1][u];
      int nxtPos = max(pos, s[i].first);
      dp[i][u] = min(dp[i][u], nxtPos + s[i].second);
    }
  }
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    ans = s[i].first - 1;
  }
  if (k == n) {
    cout << 86400 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    for (int u = 0; u <= k; u++) {
      ans = max(ans, s[i].first - dp[i - 1][u]);
    }
  }
  for (int u = 0; u <= k; u++) {
    ans = max(ans, 86401 - dp[n - 1][u]);
  }
  cout << ans << endl;
  return 0;
}
