#include <bits/stdc++.h>
using namespace std;
long f[4005][4005] = {0};
int main() {
  long n, k, i, j;
  long t, d;
  long ans = 0;
  scanf("%ld%ld", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%ld%ld", &t, &d);
    if (t - f[i - 1][k] - 1 > ans) ans = t - f[i - 1][k] - 1;
    f[i][0] = max(f[i - 1][0], t - 1) + d;
    for (j = 1; j <= k; j++)
      f[i][j] = min(max(f[i - 1][j], t - 1) + d, f[i - 1][j - 1]);
  }
  if (86400 - f[n][k] > ans) ans = 86400 - f[n][k];
  cout << ans << endl;
  return 0;
}
