#include <stdio.h>

#define DAY_MAX (24*60*60)

int train_num[DAY_MAX+1];

int main(void) {
	int n,i;
	int h,m,s;
	int max;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<=DAY_MAX;i++)train_num[i]=0;
		for(i=0;i<n;i++) {
			scanf("%d:%d:%d",&h,&m,&s);
			train_num[h*60*60+m*60+s]++;
			scanf("%d:%d:%d",&h,&m,&s);
			train_num[h*60*60+m*60+s]--;
		}
		max=0;
		for(i=1;i<=DAY_MAX;i++) {
			train_num[i]+=train_num[i-1];
			if(train_num[i]>max)max=train_num[i];
		}
		printf("%d\n",max);
	}
	return 0;
}