#include <iomanip>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include "queue"
//#include <multiset>
#include <map>
#include <utility>
#include <numeric>
#include "random"
#ifndef __clang__
#include <bits/stdc++.h>
#endif
using namespace std;

#define all(x) (x).begin(), (x).end()
#define int long long


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        int ax, bx;
        char c;
        cin >> ax >> c >> bx;
        a[i] = ax * 60 + bx;
    }
    int ans = 2;
    for (int i = 0; i + 1 < n; ++i) {
        if (a[i + 1] - a[i] <= 10)
            ans = 1;
    }
    for (int i = 0; i + 2 < n; ++i) {
        if (a[i+2] - a[i] <= 10)
            ans = 0;
    }
    cout << ans << '\n';
}

signed main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
