#include <bits/stdc++.h>
using namespace std;
template <class T>
void inline checkMax(T& a, T b) {
  if (a < b) a = b;
};
template <class T>
void inline checkMin(T& a, T b) {
  if (a > b) a = b;
};
struct Item {
  int start_time;
  int duration;
  Item() {}
  Item(int start_time, int duration)
      : start_time(start_time), duration(duration) {}
  bool operator<(Item const& other) const {
    if (start_time < other.start_time) return true;
    if (other.start_time < start_time) return false;
    return duration < other.duration;
  }
  void scan() { scanf("%d%d", &start_time, &duration); }
};
int const N = 4100;
int dp[2][N];
int const M = 86400;
int min_ignore[M + 1];
int mark_call[M + 1], sum[M + 10];
int main() {
  int n, K;
  while (~scanf("%d%d", &n, &K)) {
    vector<Item> calls(n);
    for (int n_ = (n), i = 0; i < n_; ++i) {
      calls[i].scan();
    }
    int tg = 0;
    memset(dp, 0x3f, (sizeof dp));
    dp[tg][0] = 1;
    int ans = 0;
    for (int n_ = (n + 1), r = 0; r < n_; ++r) {
      for (int n_ = (K + 1), i = 0; i < n_; ++i) {
        int next_item = r + (K - i);
        if (next_item < n) {
          checkMax(ans, calls[next_item].start_time - dp[tg][i]);
        } else {
          checkMax(ans, M + 1 - dp[tg][i]);
        }
      }
      if (r == n) {
        break;
      }
      memset(dp[tg ^ 1], 0x3f, (sizeof dp[tg ^ 1]));
      for (int n_ = (K + 1), i = 0; i < n_; ++i) {
        if (i != 0) {
          checkMin(dp[tg ^ 1][i], dp[tg][i - 1]);
        }
        checkMin(dp[tg ^ 1][i],
                 max(dp[tg][i], calls[r].start_time) + calls[r].duration);
      }
      tg ^= 1;
    }
    cout << ans << endl;
  }
  return 0;
}
