#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int n, k, t[N], d[N];
int my_time[2][N][2], my_end[2][N][2];
int max(int a, int b) { return (a > b) ? a : b; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &t[i], &d[i]);
  memset(my_time, 0, sizeof(my_time));
  memset(my_end, 0, sizeof(my_end));
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= k; j++) {
      if (i <= j) {
        my_time[i % 2][j][0] = 0;
        my_end[i % 2][j][0] = 0;
        my_time[i % 2][j][1] = 86400;
        my_end[i % 2][j][1] = 0;
        continue;
      }
      my_time[i % 2][j][0] = t[i] - my_end[(i - 1) % 2][j][1];
      my_end[i % 2][j][0] = max(my_end[(i - 1) % 2][j][1], t[i] - 1) + d[i];
      if (my_time[i % 2][j][0] < my_time[(i - 1) % 2][j][0]) {
        my_time[i % 2][j][0] = my_time[(i - 1) % 2][j][0];
        my_end[i % 2][j][0] = max(t[i] - 1, my_end[(i - 1) % 2][j][0]) + d[i];
      }
      my_end[i % 2][j][1] = max(my_end[(i - 1) % 2][j][1], t[i] - 1) + d[i];
      my_time[i % 2][j][1] = 86400 - my_end[i % 2][j][1];
      if (j > 0 && my_time[(i - 1) % 2][j - 1][1] > my_time[i % 2][j][1]) {
        my_time[i % 2][j][1] = my_time[(i - 1) % 2][j - 1][1];
        my_end[i % 2][j][1] = my_end[(i - 1) % 2][j - 1][1];
      }
    }
  cout << max(my_time[n % 2][k][0] - 1, my_time[n % 2][k][1]) << endl;
  return 0;
}
