#include <bits/stdc++.h>
using namespace std;
const int maxn = 4010;
int main() {
  static int h[maxn] = {0};
  int i, j, n, k, t, d;
  int ans = 0;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &t, &d);
    ans = max(ans, min(t, 86401) - h[k] - 1);
    for (j = k; j >= 0; j--) {
      h[j] = max(h[j] + d, t + d - 1);
      if (j > 0) h[j] = min(h[j], h[j - 1]);
    }
  }
  ans = max(ans, 86400 - h[k]);
  printf("%d\n", ans);
  return 0;
}
