#include <bits/stdc++.h>
using namespace std;
const int N = 4040;
int dp[N][N];
int n, m;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    int i, j;
    memset(dp, 63, sizeof(dp));
    memset(dp[0], 0, sizeof(dp[0]));
    int ret = 0;
    for (i = 1; i <= n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      for (j = 0; j <= m; j++) {
        int w = dp[i - 1][j];
        dp[i][j] = min(dp[i][j], max(w, x - 1) + y);
        dp[i][j + 1] = min(dp[i][j + 1], w);
        ret = max(ret, x - 1 - w);
      }
    }
    for (i = 0; i <= m; i++) ret = max(ret, 86400 - dp[n][i]);
    printf("%d\n", ret);
  }
}
