#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const int mod = (int)1e9 + 7;
const int N = (int)1e6;
const long long LLINF = (long long)1e18 + 10;
const double pi = acos(-1.0);
template <typename T1, typename T2>
bool umin(T1 &x, T2 y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, T2 y) {
  if (x < y) return x = y, true;
  return false;
}
template <typename T>
T getint() {
  char c = getchar();
  T p = 1, x = 0;
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') p = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * p;
}
int n, k;
int dp[5000][5000];
int len[5000], st[5000];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> st[i] >> len[i];
    for (int j = 0; j <= k; ++j) dp[i][j] = INF;
  }
  for (int j = 0; j <= k; ++j) dp[0][j] = INF;
  dp[0][0] = 1;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (j) umin(dp[i][j], dp[i - 1][j - 1]);
      umin(dp[i][j], max(st[i], dp[i - 1][j]) + len[i]);
      umax(ans, st[i] - dp[i - 1][j]);
    }
  }
  for (int j = 0; j <= k; ++j) {
    umax(ans, 86401 - dp[n][j]);
  }
  cout << ans;
  return 0;
}
