#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int attr;
    int time;
}Data;
int comp(const void *a,const void *b){
    Data c = *(Data *)a;
    Data d = *(Data *)b;
    if(c.time<d.time) return -1;
    else if(c.time>d.time) return 1;
    else{
        if(c.attr==0) return 1;
        else return -1;
    }
    return 0;
}
int main(void){
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0) break;
        getchar();
        Data d[20000];
        for(int i=0;i<n;i++){
            char a[10],b[10];
            scanf("%s%s",a,b);
            //printf("%s %s\n",a,b);
            int h,m,s;
            sscanf(&a[0],"%d",&h); sscanf(&a[3],"%d",&m); sscanf(&a[6],"%d",&s);
            //printf("%d %d %d\n",h,m,s);
            d[i*2].attr=0; d[i*2].time=3600*h+60*m+s;
            sscanf(&b[0],"%d",&h); sscanf(&b[3],"%d",&m); sscanf(&b[6],"%d",&s);
            d[i*2+1].attr=1; d[i*2+1].time=3600*h+60*m+s;
        }
        qsort(d,2*n,sizeof(Data),comp);
        int ans=0; int max=0;
        for(int i=0;i<2*n;i++){
            if(d[i].attr==0){
                ans++;
                if(max<ans) max=ans;
            }else{
                ans--;
            }
        }
        printf("%d\n",max);
    }
}

