#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v(4005);
int dp[4005][4005];
int main(void) {
  int n, k;
  while (cin >> n >> k) {
    v.clear();
    v.resize(n);
    for (int i = 1; i <= n; i++) {
      cin >> v[i].first >> v[i].second;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= min(i, k); j++) {
        dp[i][j] = max(dp[i - 1][j], v[i].first) + v[i].second;
        if (j) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, v[i + 1].first - dp[i][k]);
    ans = max(ans, 86401 - dp[n][k]);
    cout << ans << "\n";
  }
}
