#include <bits/stdc++.h>
using namespace std;
int t[5000], d[5000];
int dp[5000][5000];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= (n); ++i) cin >> t[i] >> d[i];
  t[0] = 1;
  t[n + 1] = 86401;
  d[0] = 0;
  int ans = t[1] - 1;
  for (int i = 1; i <= (n); ++i)
    for (int j = (0); j <= (m); ++j)
      if (i >= j) {
        int &res = dp[i][j];
        res = max(dp[i - 1][j], t[i]) + d[i];
        if (j) res = min(res, dp[i - 1][j - 1]);
        if (i == j) dp[i][j] = 1;
        ans = max(ans, t[i + 1] - dp[i][j]);
      }
  cout << ans << endl;
  return 0;
}
