#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 4100;
const int MAXS = 100100;
const int MAXT = 86400;
int n, k, tim[MAXN], dur[MAXN], d[MAXN][MAXN];
bool start[MAXS];
int getRight(int v) {
  if (v < n) return tim[v] - 1;
  return MAXT;
}
int get(int* a, int r, int value) {
  int l = 0;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (a[mid] <= value)
      r = mid;
    else
      l = mid;
  }
  for (int i = l; i <= r; i++)
    if (a[i] <= value) return i;
  throw;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (int)(n); i++) {
    cin >> tim[i] >> dur[i];
    start[tim[i]] = true;
  }
  memset(d, 60, sizeof d);
  d[0][0] = 1;
  for (int num = 0; num < (int)(n); num++)
    for (int out = 0; out < (int)(num + 1); out++) {
      int value = d[num][out];
      d[num + 1][out + 1] = min(d[num + 1][out + 1], value);
      d[num + 1][out] = min(d[num + 1][out], max(value, tim[num]) + dur[num]);
    }
  int v = 0, ans = 0;
  for (int l = 0; l < (int)(MAXT + 1); l++) {
    if (l == 0) continue;
    if (start[l]) v++;
    int cur = get(d[v], v, l);
    if (cur > k) continue;
    int r = getRight(v + k - cur);
    ans = max(ans, r - l + 1);
  }
  cout << ans << endl;
  return 0;
}
