#include <bits/stdc++.h>
using namespace std;
const long maxn = 4005;
const long inf = 1e8;
const long con = 86400;
pair<long, long> seg[maxn];
long q, n, k;
long a[maxn][maxn];
inline void upd(long x, long y, long nnew) { a[x][y] = min(a[x][y], nnew); }
int main() {
  scanf("%ld%ld", &n, &k);
  for (q = 1; q <= n; q++) {
    long t1;
    scanf("%ld%ld", &seg[q].first, &t1);
    seg[q].second = seg[q].first + t1 - 1;
    if (seg[q].second > con) seg[q].second = con;
  }
  for (long it = 0; it <= n + 1; it++)
    for (long killed = 0; killed <= it; killed++) a[it][killed] = inf;
  a[0][0] = 0;
  for (long it = 0; it < n; it++)
    for (long killed = 0; killed <= min(it, k); killed++)
      if (a[it][killed] != inf) {
        if (killed != k) upd(it + 1, killed + 1, a[it][killed]);
        if (a[it][killed] < seg[it + 1].first)
          upd(it + 1, killed, seg[it + 1].second);
        else
          upd(it + 1, killed,
              a[it][killed] + (seg[it + 1].second - seg[it + 1].first + 1));
      }
  seg[n + 1].first = con + 1;
  long answer = 0;
  for (long it = 0; it <= n; it++)
    for (long killed = 0; killed <= min(k, it); killed++)
      answer = max(answer, seg[it + 1].first - a[it][killed] - 1);
  printf("%ld", answer);
}
