#include <bits/stdc++.h>
using namespace std;
int n, k;
const int maxn = 4100;
pair<int, int> p[maxn];
int dp[maxn][maxn];
int inf = (int)(1e9);
int ans = 0;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  p[n + 1].first = 86401;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = inf;
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j <= k; j++) {
      ans = max(ans, p[i].first - dp[i - 1][j]);
      dp[i][j] = min(dp[i][j],
                     max(dp[i - 1][j] + p[i].second, p[i].first + p[i].second));
      if (j > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
    }
  }
  cout << ans << endl;
  return 0;
}
