#include <stdio.h>
#include <stdlib.h>
#define ONE_DAY 24 * 60 * 60

typedef struct{
	int start;
	int goal;
}t_set;

int input_num(void){
	int n;
	scanf("%d",&n);
	return n;
}

t_set *input_time(int n){
	t_set *ret;
	int i;
	ret = (t_set *)malloc(sizeof(t_set)*n);
	
	for(i = 0;i < n;i++){
		int j, k, l;
		
		scanf("%d:%d:%d",&j,&k,&l);
		ret[i].start = j * 60 * 60+ k * 60 + l;
		
		scanf("%d:%d:%d",&j,&k,&l);
		ret[i].goal = j * 60 * 60 + k * 60 + l;
	}
	
	return ret;
}


int main(){
	while(1){
		int t = 0;
		int n = input_num();
		int max = 0;
		int c = 0;
		t_set *time_set;
		if(n == 0){
			break;
		}
		
		time_set = (t_set *)malloc(sizeof(t_set)*n);
		time_set = input_time(n);
		
		for(t = 0; t < ONE_DAY;t++){
			int i;
			for(i = 0; i < n;i++){
				if(t == time_set[i].start){
					c++;
					if(max < c){
						max = c;
					}
				}
				else if(t == time_set[i].goal){
					c--;
				}
			}
		}
		printf("%d\n",max);
	}
	
	return 0;
}
//vim: set ft=C fenc=utf-8 ff=unix ts=4 sw=4: