#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
vector<string> split(const string& s, const string& delim = " ") {
  vector<string> res;
  string t;
  for (int i = 0; i < s.size(); i++) {
    if (delim.find(s[i]) != string::npos) {
      if (!t.empty()) {
        res.push_back(t);
        t = "";
      }
    } else {
      t += s[i];
    }
  }
  if (!t.empty()) {
    res.push_back(t);
  }
  return res;
}
template <typename T>
inline void checkmax(T& a, const T& b) {
  if (a < b) a = b;
}
int f[5003][5003];
int t[5003 * 2];
int d[5003];
int main() {
  int n, k, i;
  while (cin >> n >> k) {
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &t[i], &d[i]);
      t[i + n] = 86400 + 1;
    }
    if (n == k) {
      puts("86400");
      continue;
    }
    int res = 0;
    f[0][0] = 1;
    checkmax(res, t[k + 1] - f[0][0]);
    for (int i = 1; i <= n; i++) {
      f[i][0] = max(f[i - 1][0], t[i]) + d[i];
      checkmax(res, t[i + k + 1] - f[i][0]);
      for (int j = 1; j <= k && j <= i; j++) {
        f[i][j] = min(f[i - 1][j - 1], max(f[i - 1][j], t[i]) + d[i]);
        checkmax(res, t[i + k - j + 1] - f[i][j]);
      }
    }
    cout << res << endl;
  }
}
