#include <bits/stdc++.h>
using namespace std;
struct call {
  int t, d;
};
int dp1[4003][4003];
int dp2[4003][4003];
call arr[4003];
int n, k;
int day_end = 86400;
bool comp(call a, call b) { return (a.t < b.t) || (a.t == b.t && a.d < b.d); }
int get_sleep_duration(int i, int j, int q) {
  if (q < 0) q = 0;
  if (q > i) return -1000000000;
  int en1 = dp1[i][q];
  int st2 = max(en1 + 1, arr[j].t);
  return st2 - en1 - 1;
}
int main() {
  cin >> n >> k;
  if (n == 0 || n - k == 0) {
    cout << day_end << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) cin >> arr[i].t >> arr[i].d;
  sort(arr + 1, arr + n + 1, comp);
  if (n - k == 1) {
    int res = 0;
    for (int i = 1; i <= n; i++) {
      int en = arr[i].t + arr[i].d - 1;
      res = max(res, max(arr[i].t - 1, day_end - en));
    }
    cout << res << endl;
    return 0;
  }
  dp1[1][0] = 0;
  dp1[1][1] = arr[1].t + arr[1].d - 1;
  for (int i = 2; i <= n; i++) {
    dp1[i][0] = 0;
    for (int j = 1; j < i; j++) {
      dp1[i][j] = dp1[i - 1][j];
      int last_end = 0;
      if (j - 1 > 0) last_end = dp1[i - 1][j - 1];
      int en = max(arr[i].t, last_end + 1) + arr[i].d - 1;
      if (en < dp1[i - 1][j]) dp1[i][j] = en;
    }
    dp1[i][i] = max(dp1[i - 1][i - 1] + 1, arr[i].t) + arr[i].d - 1;
  }
  int res = 0;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      int q = n - k - 1 - (n - j);
      res = max(res, get_sleep_duration(i, j, q));
    }
  res = max(res, arr[n - (n - k) + 1].t - 1);
  res = max(res, day_end - dp1[n][n - k]);
  cout << res << endl;
  return 0;
}
