#include <bits/stdc++.h>
using namespace std;
template <class Ta, class Tb>
inline Tb cast(Ta a) {
  stringstream ss;
  ss << a;
  Tb b;
  ss >> b;
  return b;
};
const int INF = 1000000000;
const int MOD = 1000000007;
const int diri[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int dirj[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, K;
int start[4010], duration[4010];
int dp[4010][4010];
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> start[i] >> duration[i];
    --start[i];
  }
  for (int k = 0; k <= K; ++k) dp[0][k] = 0;
  for (int n = 1; n <= N; ++n)
    for (int k = 0; k <= K; ++k) {
      dp[n][k] = max(dp[n - 1][k], start[n - 1]) + duration[n - 1];
      if (k > 0) dp[n][k] = min(dp[n][k], dp[n - 1][k - 1]);
    }
  int res = 0;
  for (int n = 0; n <= N; ++n) {
    for (int k = 0; k <= K; ++k) {
      int a = dp[n][k];
      int b = 86400;
      if (n + (K - k) < N) b = start[n + (K - k)];
      res = max(res, b - a);
    }
  }
  cout << res << endl;
}
