#include <bits/stdc++.h>
using namespace std;
void setIO(string name) {
  string is = name + ".in", os = name + ".out";
  freopen(is.c_str(), "r", stdin);
  freopen(os.c_str(), "w", stdout);
}
int f[5000][5000], ans, n, s[5000], v[5000], k, t;
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= k; j++) f[i][j] = 0x7FFFFFFF;
  for (int i = 0; i <= k; i++) f[0][i] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j]);
      if (f[i][j] <= s[i]) {
        if (s[i] < 86401)
          ans = max(ans, s[i] - f[i][j]);
        else
          ans = max(ans, 86401 - f[i][j]);
        f[i + 1][j] = min(f[i + 1][j], s[i] + v[i]);
      } else {
        f[i + 1][j] = min(f[i + 1][j], f[i][j] + v[i]);
      }
    }
  }
  for (int j = 0; j <= k; j++)
    if (f[n][j] < 86401) ans = max(ans, 86401 - f[n][j]);
}
void work() {
  scanf("%d %d", &n, &k);
  if (n == 0 || n <= k) {
    printf("86400\n");
    return;
  }
  for (int i = 0; i < n; i++) scanf("%d %d", s + i, v + i);
  solve();
  printf("%d\n", ans);
}
int main() {
  work();
  return 0;
}
