#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
int finish[N][N], bestTime = 0;
pair<int, int> call[N];
int main() {
  int n, canSkip, skip, i, begini;
  scanf("%d%d", &n, &canSkip);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &call[i].first, &call[i].second);
  }
  for (skip = 0; skip <= canSkip; ++skip) {
    for (finish[skip][0] = i = 1; i <= n; ++i) {
      begini = max(finish[skip][i - 1], call[i].first);
      bestTime = max(bestTime, begini - finish[skip][i - 1]);
      finish[skip][i] = begini + call[i].second;
      if (skip != 0) {
        finish[skip][i] = min(finish[skip][i], finish[skip - 1][i - 1]);
      }
    }
    bestTime = max(bestTime, 86401 - finish[skip][n]);
  }
  printf("%d\n", bestTime);
  return 0;
}
