#include <bits/stdc++.h>
using namespace std;
int f[4010][4010];
int main() {
  int n, k;
  int ans;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    int t, d;
    cin >> t >> d;
    ans = max(ans, t - f[i - 1][k] - 1);
    f[i][0] = max(f[i - 1][0], t - 1) + d;
    for (int j = 1; j <= k; ++j) {
      f[i][j] = min(max(f[i - 1][j], t - 1) + d, f[i - 1][j - 1]);
    }
  }
  cout << max(ans, 86400 - f[n][k]) << endl;
  return 0;
}
