#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int A[100005], B[100005];
  int cnt[200001] = {};

  int sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    sum += A;
    if (sum >= 86400) sum %= 86400;
    cnt[sum]++;
    sum += B;
    if (sum >= 86400) sum %= 86400;
  }
  for (int i = 86400; i < 200001; i++) {
    cnt[i] = cnt[i-86400];
  }
  int maxv = 0;
  int now = 0;
  for (int i = 0; i < 10801; i++) {
    maxv += cnt[i];
  }
  now = maxv;
  for (int i = 10801; i < 200001; i++) {
    now -= cnt[i-10801];
    now += cnt[i];
    maxv = max(maxv, now);
  }
  cout << maxv << endl;
  return (0);
}
