#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
const int maxn = 4050;
const int maxsec = 86400;
vector<pair<int, int> > input;
int dp[maxn][maxn];
int main() {
  int k, n;
  scanf("%d", &n);
  ;
  scanf("%d", &k);
  ;
  int i, j;
  int x, y;
  for (i = 0; i < n; ++i) {
    scanf("%d", &x);
    ;
    scanf("%d", &y);
    ;
    input.push_back(make_pair(x - 1, y));
  }
  if (k >= n) {
    printf("%d\n", maxsec);
    ;
    return 0;
  }
  sort(input.begin(), input.end());
  int m = input.size();
  dp[0][0] = input[0].first + input[0].second;
  for (j = 1; j <= k; ++j) dp[0][j] = 0;
  for (i = 1; i < m; ++i) {
    dp[i][0] = max(input[i].first, dp[i - 1][0]) + input[i].second;
    for (j = 1; j <= k; ++j) {
      dp[i][j] = min(dp[i - 1][j - 1],
                     max(dp[i - 1][j], input[i].first) + input[i].second);
    }
  }
  int ans = input[k].first;
  int wakeup;
  for (i = 0; i < m; ++i)
    for (j = 0; j <= k; ++j) {
      if (i + k - j + 1 < m)
        wakeup = input[i + k - j + 1].first;
      else
        wakeup = maxsec;
      ans = max(ans, wakeup - dp[i][j]);
    }
  printf("%d\n", ans);
  ;
  return 0;
}
