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

typedef pair<long long, long long> P;
void solve(int n){
	vector<int> v;
	vector<P> w;
	for(int i=0; i<n; ++i){
		int a, b, h, m, s;
		scanf("%d:%d:%d", &h, &m, &s);
		a = 3600*h + 60*m + s;
		scanf("%d:%d:%d", &h, &m, &s);
		b = 3600*h + 60*m + s;
		w.push_back(P(a, b));
	}
	sort(w.begin(), w.end());
	for(int i=0; i<n; ++i){
		int a = w[i].first;
		int b = w[i].second;
		bool f = false;
		for(int j=0; j<v.size(); ++j)
			if(v[j] <= a){
				v[j] = b;
				f = true;
				break;
			}
		if(!f) v.push_back(b);
		sort(v.begin(), v.end());
	}
	cout << v.size() << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}
