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