#include <bits/stdc++.h>
int max(int a, int b) { return a > b ? a : b; }
int main() {
  static int tt[4000], dd[4000], dp[86400 + 1], dq[86400 + 1];
  int n, k, i, m, t, ans;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d%d", &tt[i], &dd[i]);
  ans = (k == n ? 86400 + 1 : tt[k]) - 1;
  for (m = 1; m <= n; m++) {
    for (t = 1; t <= 86400; t++) {
      int x = max(dp[t], dq[t - 1]);
      if (tt[m - 1] + dd[m - 1] - 1 <= t) x = max(x, dp[t - dd[m - 1]] + 1);
      dq[t] = x;
      if (m - x <= k) {
        int t_;
        i = m + (k - (m - x));
        t_ = i >= n ? 86400 + 1 : tt[i];
        ans = max(ans, t_ - t - 1);
      }
    }
    for (t = 1; t <= 86400; t++) dp[t] = dq[t];
  }
  printf("%d\n", ans);
  return 0;
}
