#include <bits/stdc++.h>
using namespace std;
const int Day = 86400;
const long long INF = 1e18;
const int N = 4004;
long long dp[N][N], t[N], d[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int(i) = 0; (i) < (n); (i)++) scanf("%d%d", &t[i], &d[i]), t[i]--;
  if (n == k) return printf("%d\n", Day) & 0;
  memset(dp, INF, sizeof dp);
  dp[0][0] = 0;
  for (int(i) = (1); (i) <= (n); (i)++)
    for (int(j) = (0); (j) <= (k); (j)++)
      if (j <= i) {
        long long last = dp[i - 1][j];
        if (last != INF) {
          dp[i][j] = max(last, t[i - 1]) + d[i - 1];
        }
        if (j > 0) dp[i][j] = min(dp[i - 1][j - 1], dp[i][j]);
      }
  long long ans = 0;
  for (int(left) = (0); (left) <= (n); (left)++) {
    int right = min(k, left);
    long long start = dp[left][right];
    long long finish = left < n ? t[left] : Day;
    if (start >= Day || finish > Day || start >= finish) continue;
    ans = max(ans, finish - start);
  }
  printf("%I64d\n", ans);
  return 0;
}
