#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[4400], b[4400];
int f[4400][4400];
int ans;
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    ans = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d%d", &a[i], &b[i]);
    }
    if (n <= k) ans = 86400;
    for (int j = 0; j <= k; ++j) f[0][j] = 1;
    for (int i = 1; i <= n; ++i)
      for (int j = 0; j <= min(k, i); ++j) {
        if (j) {
          f[i][j] = min(f[i - 1][j - 1], max(f[i - 1][j], a[i]) + b[i]);
        } else {
          f[i][j] = max(f[i - 1][j], a[i]) + b[i];
        }
        int l = i + (k - j) + 1;
        int end = 0;
        if (l <= n)
          end = a[l] - 1;
        else
          end = 86400;
        ans = max(ans, end - f[i][j] + 1);
      }
    printf("%d\n", ans);
  }
  return 0;
}
