#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4000;
int dp[MAXN + 1][MAXN + 1];
int t[MAXN + 2], d[MAXN + 1];
int main(void) {
  int n, k;
  cin >> n >> k;
  if (n == 0) {
    cout << 86400 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> d[i];
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = max(dp[i - 1][j], t[i] - 1) + d[i];
      if (j > 0) {
        dp[i][j] = min(dp[i - 1][j - 1], dp[i][j]);
      }
    }
  }
  t[n + 1] = 86401;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      int tmp = i + k - j + 1;
      if (tmp > n) {
        tmp = n + 1;
      }
      ans = max(t[tmp] - dp[i][j] - 1, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
