#include <bits/stdc++.h>
using namespace std;
int dt[4239][4239], den[4239][4239];
int main() {
  int n, k;
  cin >> n >> k;
  int t[4239], d[4239];
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &t[i], &d[i]);
  }
  t[n + 1] = 86401;
  dt[0][0] = 0;
  den[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dt[i][0] = max(dt[i - 1][0], t[i] - den[i - 1][0]);
    den[i][0] = max(t[i] + d[i], den[i - 1][0] + d[i]);
  }
  for (int i = 1; i <= k; i++) {
    dt[i][i] = t[i + 1] - 1;
    den[i][i] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= k && j < i; j++) {
      dt[i][j] = max(t[i] - den[i - 1][j], dt[i - 1][j]);
      dt[i][j] =
          max(dt[i][j], max(dt[i - 1][j - 1], t[i + 1] - den[i - 1][j - 1]));
      den[i][j] = max(den[i - 1][j] + d[i], t[i] + d[i]);
      den[i][j] = min(den[i][j], den[i - 1][j - 1]);
    }
  }
  cout << min(max(dt[n][k], t[n + 1] - den[n][k]), 86400);
  return 0;
}
