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