#include <bits/stdc++.h>
using namespace std;
int dp[4005][4005];
void input() {
  int i, j, res = 0;
  int t, len, n, k;
  scanf("%d %d", &n, &k);
  for ((i) = (0); (i) <= (n); (i)++)
    for ((j) = (0); (j) <= (k); (j)++) dp[i][j] = 1;
  for ((i) = (1); (i) <= (n); (i)++) {
    scanf("%d %d", &t, &len);
    for ((j) = (0); (j) <= (k); (j)++) {
      if (dp[i - 1][j] < t) {
        res = ((res) > (t - dp[i - 1][j]) ? (res) : (t - dp[i - 1][j]));
        dp[i][j] = t + len;
      } else
        dp[i][j] = dp[i - 1][j] + len;
      if (j)
        dp[i][j] =
            ((dp[i][j]) < (dp[i - 1][j - 1]) ? (dp[i][j]) : (dp[i - 1][j - 1]));
    }
  }
  for ((i) = (0); (i) <= (k); (i)++)
    res = ((res) > (86400 - dp[n][i] + 1) ? (res) : (86400 - dp[n][i] + 1));
  printf("%d", res);
}
int main() {
  input();
  return 0;
}
