/**
 *    author:  tourist
 *    created: 08.11.2024 23:25:19
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int h = int(s[0] - '0');
    int m = int(s[2] - '0') * 10 + int(s[3] - '0');
    a[i] = h * 60 + m;
  }
  for (int i = 0; i < n - 2; i++) {
    if (a[i + 2] - a[i] <= 10) {
      cout << 0 << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] <= 10) {
      cout << 1 << '\n';
      return 0;
    }
  }
  cout << 2 << '\n';
  return 0;
}
