#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n==1){
        cout << 2 ;
        return 0;
    }
    vector<int> a(n,0);
    for(int i = 0; i < n; ++i){
        char in;
        cin >> in;
        a[i] += 60* (in-'0');
        cin >> in;
        cin >> in;
        a[i] += 10*(in-'0');
        cin >> in;
        a[i]+=(in-'0');
    }
    a.erase(unique(a.begin(),a.end()),a.end());
    n=a.size();
    int ans = 3;
    for(int i = 0; i < n-2; ++i){
        if(a[i+2]-a[i] <= 10){
            cout << 0;
            return 0;
        }
    }
    for(int i= 0; i < n-1; ++i){
        if(a[i+1]-a[i] <=10 && a[i+1]-a[i] > 1){
            cout<< 1;
            return 0;
        }
        if(a[i+1]-a[i] <=9 && a[i+1]-a[i]>0){
            cout <<1;
            return 0;
        }
    }
    cout << 2;
}