#include <bits/stdc++.h>
using namespace std;
int n, k, t[4005], d[4005], dp[4005][4005];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> d[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = 86401;
    }
  }
  int ans = 0;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j != k) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      if (dp[i][j] < t[i]) {
        ans = max(ans, t[i] - dp[i][j]);
        dp[i + 1][j] = min(dp[i + 1][j], t[i] + d[i]);
      } else {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + d[i]);
      }
    }
  }
  for (int j = 0; j <= k; j++) {
    ans = max(ans, 86401 - dp[n][j]);
  }
  cout << ans << endl;
  return 0;
}
