#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int a[4096][2];
int dp[4096][4096];
int n, m;
int main() {
  int i, j, ret = 0, t1, t2;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a[i][0], &a[i][1]);
    a[i][0]--;
    a[i][1] += a[i][0];
  }
  qsort(a, n, sizeof(a[0]), cmp);
  for (i = j = 0; i < n; i++) {
    if (a[i][0] > j) {
      if (a[i][0] - j > ret) ret = a[i][0] - j;
      j = a[i][1];
    } else {
      j += a[i][1] - a[i][0];
    }
  }
  if (86400 - j > ret) ret = 86400 - j;
  memset(dp, 0xff, sizeof(dp));
  dp[0][0] = 0;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++)
      if (dp[i][j] >= 0) {
        if (i + m - j >= n)
          t2 = 86400;
        else
          t2 = a[i + m - j][0];
        if (t2 > dp[i][j] && t2 - dp[i][j] > ret) ret = t2 - dp[i][j];
        if (i == n) continue;
        if (dp[i][j] <= a[i][0])
          t1 = a[i][1];
        else
          t1 = dp[i][j] + a[i][1] - a[i][0];
        if (dp[i + 1][j] < 0 || dp[i + 1][j] > t1) dp[i + 1][j] = t1;
        if (j < m) {
          if (dp[i + 1][j + 1] < 0 || dp[i + 1][j + 1] > dp[i][j])
            dp[i + 1][j + 1] = dp[i][j];
        }
      }
  printf("%d\n", ret);
  return 0;
}
