#include <bits/stdc++.h>
using namespace std;
struct info {
  int t, d;
} a[4001];
int n, k, dp[4001][4001], ans;
bool cmp(info x, info y) { return x.t < y.t; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].t, &a[i].d);
  }
  if (n == k) {
    printf("86400");
    return 0;
  }
  sort(a + 1, a + 1 + n, cmp);
  a[n + 1].t = 86401;
  dp[1][0] = a[1].t + a[1].d - 1;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = max(a[i].t - 1, dp[i - 1][0]) + a[i].d;
    for (int j = 1; j <= i && j <= k; j++) {
      int tmp(a[i].t - 1);
      if (i > j) tmp = max(tmp, dp[i - 1][j]);
      dp[i][j] = min(tmp + a[i].d, dp[i - 1][j - 1]);
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= k; j++) {
      int tmp = min(n + 1, k - j + i + 1);
      ans = max(ans, a[tmp].t - 1 - dp[i][j]);
    }
  printf("%d", ans);
}
