#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4011;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
struct data {
  int x, y;
};
int n, K;
data a[MAXN];
int f[MAXN][MAXN];
void init() {
  cin >> n >> K;
  for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
}
void solve() {
  int ret = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= K; j++) {
      f[i][j] = INF / 2;
      if (f[i - 1][j] + 1 < a[i].x) {
        ret = max(ret, a[i].x - f[i - 1][j] - 1);
        f[i][j] = a[i].x + a[i].y - 1;
      } else {
        f[i][j] = min(f[i][j], f[i - 1][j] + a[i].y);
      }
      if (j > 0) {
        f[i][j] = min(f[i][j], f[i - 1][j - 1]);
      }
    }
  ret = max(ret, 86400 - f[n][K]);
  cout << ret << endl;
}
int main() {
  init();
  solve();
  return 0;
}
