#include <bits/stdc++.h>
using namespace std;
const int N = 4000;
const int INF = 4000 * 86400;
int t[N], d[N], v[N], n, k;
int dp[N][N + 1];
bool is_important(int i) { return false; }
int main() {
  ios::sync_with_stdio(0);
  while (cin >> n >> k) {
    for (int i = 0; i < n; i++) cin >> t[i] >> d[i];
    for (int i = 0; i < n; i++)
      for (int j = 0; j <= n; j++) {
        if (i == 0) {
          if (j == 0)
            dp[i][j] = t[0] + d[0];
          else if (!is_important(i))
            dp[i][j] = 1;
          else
            dp[i][j] = t[0] + d[0];
        } else if (!is_important(i))
          dp[i][j] =
              min((j ? dp[i - 1][j - 1] : INF), max(dp[i - 1][j], t[i]) + d[i]);
        else
          dp[i][j] = max(dp[i - 1][j], t[i]) + d[i];
      }
    int ans = max(86401 - (n ? dp[n - 1][k] : 1), t[0] - 1);
    for (int i = 1; i < n; i++)
      ans = max(ans, min(t[i] - dp[i - 1][k], 86401 - dp[i - 1][k]));
    cout << max(ans, 0) << "\n\n";
  }
}
