#include <stdio.h>
#include <stdlib.h>
#define MAX_TIME 24 * (60 * 60) + 60 * 60 + 60
#define LOCK 1
#define FREE 0
#define FIN 2;

typedef struct{
        unsigned int start;
        unsigned int goal;
        unsigned int lock;
}TSS;
//train_Schedule_sec

typedef struct{
        int hh;
        int mm;
        int ss;
}T_24;

T_24 *input_time(int n){
        T_24 *ret;
        ret = (T_24 *)malloc(sizeof(T_24)*(n*2));
        int i;
        
        for(i = 0;i<n*2;i += 2){
                //start
                scanf("%d:%d:%d",&ret[i].hh ,&ret[i].mm ,&ret[i].ss);
                //goal
                scanf("%d:%d:%d",&ret[i+1].hh ,&ret[i+1].mm ,&ret[i+1].ss);
        }
        
        return ret;
}

TSS *convert_sec(T_24 *input,int n){
        int i,j;
        TSS *ret;
        ret = (TSS *)malloc(sizeof(TSS)*n);
        j = 0;
        for(i = 0; i < n * 2;i += 2){
                ret[j].start = (input[i].hh * (60 * 60)) + (input[i].mm * 60) + input[i].ss;
                ret[j].goal = (input[i+1].hh *(60 * 60)) + (input[i+1].mm * 60) + input[i+1].ss;
                ret[j].lock = FREE;
                j++;
        }
        
        
        return ret;
}


int main(){
        int n;
        int i;
        int t;
        
        while(1){
                int t_max=0;
                int t_now=0;
                scanf("%d",&n);
                //printf("n:%d\n",n);
                if(n == 0){
                        break;
                }
                
                TSS *timeList;
                timeList = (TSS *)malloc(sizeof(TSS)*n);
                timeList = convert_sec(input_time(n),n);
                
                for(t = 0;t < MAX_TIME;t ++){
                        for(i = 0;i < n;i ++){
                                if(timeList[i].start == t){
                                        timeList[i].lock = LOCK;
                                        t_now ++;
                                        if(t_now>t_max){
                                                t_max = t_now;
                                        }
                                }
                                if(timeList[i].goal == t){
                                        timeList[i].lock = FIN;
                                        t_now--;
                                }
                        }
                }
                printf("%d\n",t_max);
        }
        
        return 0;
}
//vim: set ft=C fenc=utf-8 ff=unix ts=4 sw=4: