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