#include <bits/stdc++.h>
const long long md = 1e9 + 7;
const int Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 1e7 + 2;
const long long MaxM = 11;
const long double eps = 1e-15;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
const long long ddx[4] = {1, 1, -1, -1};
const long long ddy[4] = {1, -1, 1, -1};
const long double Pi = acos(-1);
using namespace std;
long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
long long gcdex(long long a, long long mod = md) {
  long long g = mod, r = a, x = 0, y = 1;
  while (r != 0) {
    long long q = g / r;
    g %= r;
    swap(g, r);
    x -= q * y;
    swap(x, y);
  }
  return x < 0 ? x + mod : x;
}
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= md;
    }
    a *= a;
    a %= md;
    n >>= 1;
  }
  return res % md;
}
long long Ch(long long N, long long M, long long K) {
  long long res = 0;
  K--;
  for (int i = 1; i <= N; i++) {
    res += min(M, K / i);
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cout << fixed, cout.precision(10);
  long long N, K;
  cin >> N >> K;
  vector<long long> St(N);
  vector<long long> Len(N);
  for (int i = 0; i < N; i++) {
    cin >> St[i] >> Len[i];
  }
  long long Ans = 0;
  vector<vector<long long> > dp(N + 1, vector<long long>(K + 1, Inf64));
  dp[0][0] = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      if (j > i) break;
      long long r = i + K - j;
      if (r >= N) {
        Ans = max(Ans, 86400 - dp[i][j] + 1);
      } else {
        Ans = max(Ans, St[r] - dp[i][j]);
      }
      if (i == N) continue;
      dp[i + 1][j] = min(dp[i + 1][j], max(St[i] + Len[i], dp[i][j] + Len[i]));
      if (j < K) dp[i + 1][j + 1] = min(dp[i][j], dp[i + 1][j + 1]);
    }
  }
  cout << Ans;
  cerr << '\n'
       << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec"
       << '\n';
  return 0;
}
