#include <bits/stdc++.h>
using namespace std;
int a[4007][2], r[40007];
int dp[4007][4007];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i][0] >> a[i][1];
  a[n + 1][0] = 86401;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= k; j++) {
      if (j >= i)
        dp[i][j] = 0;
      else if (j == 0)
        dp[i][j] = max(dp[i - 1][j] + 1, a[i][0]) + a[i][1] - 1;
      else
        dp[i][j] =
            min(max(dp[i - 1][j] + 1, a[i][0]) + a[i][1] - 1, dp[i - 1][j - 1]);
    }
  int mx = 0;
  for (int i = 0; i <= n; i++) mx = max(mx, a[i + 1][0] - dp[i][k] - 1);
  cout << mx;
  return 0;
}
