#include <bits/stdc++.h>
using namespace std;
int f[4444][4444];
int a[4444][2];
int n, ans = 0, k;
int main() {
  scanf("%d%d", &n, &k);
  if (n == 0) {
    cout << 86400 << endl;
    return 0;
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) f[i][j] = 1000000000;
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i][0], &a[i][1]);
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int lim = min(k, i);
    for (int j = 0; j <= lim; j++) {
      if (j) f[i][j] = f[i - 1][j - 1];
      ans = max(ans, a[i][0] - f[i - 1][j]);
      f[i][j] = min(f[i][j], max(f[i - 1][j], a[i][0]) + a[i][1]);
      if (i == n) ans = max(ans, 86400 - f[i][j] + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
