#include <bits/stdc++.h>
using namespace std;
int t[4050], d[4050], n, k, f[4050][4050];
int main() {
  t[0] = d[0] = 0;
  const int day = 86400;
  while (scanf("%d%d", &n, &k) != -1) {
    int ans = 0;
    for (int i = 1; i <= n; i++) scanf("%d%d", &t[i], &d[i]);
    t[n + 1] = day + 1;
    d[n + 1] = 0;
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) f[i][0] = max(f[i - 1][0], t[i]) + d[i];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= i && j <= k; j++) {
        f[i][j] = min(f[i - 1][j - 1], f[i][j - 1]);
        if (i - 1 >= j)
          f[i][j] = min(f[i - 1][j - 1], max(f[i - 1][j], t[i]) + d[i]);
      }
    for (int i = 0; i <= n; i++) {
      int tm = min(i, k);
      ans = max(ans, t[i + 1] - f[i][tm]);
    }
    printf("%d\n", ans);
  }
}
