#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4000 + 17;
const int MAXM = 100000 + 17;
const int INF = 0x7fffffff;
const int MOD = 1e9 + 7;
struct call {
  int t, d;
} all[MAXN];
int dp[MAXN][MAXN];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) scanf("%d%d", &all[i].t, &all[i].d);
  dp[1][0] = all[1].t + all[1].d - 1;
  dp[1][1] = 0;
  all[n + 1].t = 86401;
  dp[0][0] = dp[0][1] = 0;
  for (int i = 2; i <= n; ++i) {
    dp[i][0] = max(dp[i - 1][0], all[i].t - 1) + all[i].d;
    for (int j = 1; j <= min(i, k); ++j)
      dp[i][j] =
          min(max(dp[i - 1][j], all[i].t - 1) + all[i].d, dp[i - 1][j - 1]);
  }
  int ans = 0;
  for (int i = 1; i <= n + 1; ++i)
    ans = max(all[i].t - dp[i - 1][min(i, k)] - 1, ans);
  cout << ans << endl;
}
