#include <bits/stdc++.h>
using namespace std;
int dp[4096][4096];
void filldp(vector<int> &vec1, vector<int> &vec2) {
  for (int i = 0; i < (int)4096; i++)
    for (int j = 0; j < (int)4096; j++) dp[i][j] = 86400;
  int n = vec1.size();
  dp[0][0] = vec1[0] + vec2[0];
  for (int i = 0; i < (int)n; i++) dp[i][i + 1] = 0;
  for (int i = 1; i < n; i++)
    for (int j = i; j >= 0; j--) {
      if (dp[i - 1][j] > vec1[i])
        dp[i][j] = dp[i - 1][j] + vec2[i];
      else
        dp[i][j] = vec1[i] + vec2[i];
      if (j != 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
    }
  return;
}
int calc(vector<int> &vec1, vector<int> &vec2, int t, int pos) {
  if (pos <= t) return vec1[pos];
  return max(vec1[pos] - dp[pos - 1][t], 0);
}
int main() {
  int n, t;
  cin >> n >> t;
  vector<int> vec1(n), vec2(n);
  for (int i = 0; i < (int)n; i++) {
    cin >> vec1[i] >> vec2[i];
    vec1[i]--;
  }
  vec1.push_back(86400);
  vec2.push_back(1);
  n++;
  int res = 0;
  if (n == t)
    cout << 86400 << endl;
  else {
    filldp(vec1, vec2);
    for (int i = 0; i < (int)n; i++) {
      res = max(res, calc(vec1, vec2, t, i));
    }
    cout << res << endl;
  }
}
