#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
const int INF = 1000000000;
int max(const int &x, const int &y) { return x > y ? x : y; }
struct P {
  int s, d;
} data[N];
bool cmp(P x, P y) { return x.s < y.s; }
int dp[N][N];
int main() {
  int i, j, k, n;
  scanf("%d%d", &n, &k);
  if (n == 0 && k == 0) {
    puts("86400");
    return 0;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &data[i].s, &data[i].d);
  }
  sort(data + 1, data + 1 + n, cmp);
  int r = data[1].s - 1;
  for (i = 0; i <= k; i++)
    for (j = 0; j <= n; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (i = 0; i <= k; i++) {
    for (j = 1; j <= n; j++) {
      dp[i][j] = max(dp[i][j - 1] + data[j].d, data[j].s + data[j].d - 1);
      if (i && dp[i][j] > dp[i - 1][j - 1]) dp[i][j] = dp[i - 1][j - 1];
    }
  }
  data[n + 1].s = 86401;
  for (i = 0; i <= k; i++)
    for (j = 1; j <= n; j++) {
      if (r < data[j + 1].s - dp[i][j] - 1) r = data[j + 1].s - dp[i][j] - 1;
    }
  printf("%d\n", r);
  return 0;
}
