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