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

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N;
	cin >> N;
	set<int> times;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		assert(s[1] == ':');
		int h = (s[0] - '0');
		int m = (s[2] - '0') * 10 + (s[3] - '0');
		int t = 60 * (h - 7) + m;
		times.insert(t);
	}
	int ans = 0;
	for(int x : times){
		int c = 0;
		for(int y = x; y <= x+10; y++){
			if(times.count(y)) c++;
		}
		ans = max(ans, c);
	}
	cout << (3 - min(ans, 3)) << '\n';
}
