#include <bits/stdc++.h>
using namespace std;
int t[10000], d[10000];
int N, K;
int dp[10000];
int main() {
  while (scanf("%d %d", &N, &K) == 2) {
    for (int i = 1; i <= N; i++) {
      scanf("%d %d", &t[i], &d[i]);
    }
    t[0] = 0;
    d[0] = 0;
    t[N + 1] = 86401;
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 1;
    int ans = 0;
    for (int i = 0; i <= N; i++) {
      for (int j = K; j >= 0; j--) {
        if (dp[j] < dp[j + 1]) dp[j + 1] = dp[j];
        if (dp[j] < t[i]) dp[j] = t[i];
        dp[j] += d[i];
      }
      for (int j = K; j >= 0; j--)
        if (t[i + 1] - dp[j] > ans) ans = t[i + 1] - dp[j];
    }
    printf("%d\n", ans);
  }
  return 0;
}
