#include <bits/stdc++.h>
using namespace std;
std::vector<pair<long long, long long> > v;
long long dp[4005][4005] = {};
int main() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  v.push_back(make_pair(0, 0));
  for (int i = 0; i < n; i++) {
    long long t, d;
    scanf("%lld", &t);
    scanf("%lld", &d);
    v.push_back(make_pair(t, d));
  }
  long long ans = -1;
  dp[0][0] = 0;
  v.push_back(make_pair(86401, -8));
  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(v[i].first, dp[i - 1][0] + 1) + (v[i].second - 1);
    for (int j = 1; j <= k; j++) {
      if (i == 0)
        dp[i][j] = 0;
      else {
        dp[i][j] = min(min(dp[i - 1][j - 1], dp[i][j - 1]),
                       (max(dp[i - 1][j] + 1, v[i].first) + (v[i].second - 1)));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = v[i + 1].first - dp[i][k] - 1;
    ans = max(tmp, ans);
  }
  if (n == 0) ans = 86400;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
