#include <bits/stdc++.h>
#pragma hdrstop
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
long long n, k;
long long dp[5000][5000];
vector<pair<long long, long long> > a;
long long b[5000];
void solve() {
  cin >> n >> k;
  a.push_back(make_pair(1, 0));
  b[0] = 1;
  for (long long i = 0; i < n; i++) {
    long long q, w;
    cin >> q >> w;
    a.push_back(make_pair(q, w));
    b[i + 1] = q;
  }
  a.push_back(make_pair(86401, 0));
  b[n + 1] = 86401;
  long long border = 0;
  for (long long i = 0; i <= n + 5; i++)
    for (long long j = 0; j <= i; j++) dp[i][j] = (1LL << 50);
  dp[0][0] = 1;
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= i; j++) {
      pair<long long, long long> cur = a[i + 1];
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      long long now = max(b[i + 1], dp[i][j]) + cur.second;
      dp[i + 1][j] = min(dp[i + 1][j], now);
    }
  long long ans = 0;
  for (long long i = 1; i <= n + 1; i++) {
    for (long long j = 0; j <= k; j++) {
      long long cur = dp[i - 1][j];
      long long now = b[i];
      ans = max(ans, now - cur);
    }
  }
  cout << ans;
}
