#include <bits/stdc++.h>
using namespace std;
int f[4040][4040], n, k, ans;
struct info {
  int be, ti;
} e[4040];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &e[i].be, &e[i].ti);
  e[n + 1].be = 86401;
  if (n == k) {
    printf("86400");
    return 0;
  }
  f[1][0] = e[1].be + e[1].ti - 1;
  for (int i = 2; i <= n; i++) {
    f[i][0] = max(e[i].be + e[i].ti - 1, f[i - 1][0] + e[i].ti);
    for (int j = 1; j <= min(i, k); j++) {
      if (i - 1 >= j)
        f[i][j] = min(max(f[i - 1][j] + e[i].ti, e[i].be + e[i].ti - 1),
                      f[i - 1][j - 1]);
      else
        f[i][j] = min(e[i].be + e[i].ti - 1, f[i - 1][j - 1]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      ans = max(ans, e[min(n + 1, k - j + i + 1)].be - f[i][j] - 1);
    }
  }
  printf("%d", ans);
}
