//
//  main.c
//  Osaki
//
//  Created by x15071xx on 2016/06/21.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>
#define DAY 86400
int main(int argc, const char * argv[]) {
    
    int i,j,k;
    //scanf("%d %d",&i,&j);
    //printf("%d %d",i,j);
    while (1) {
        
        int n;
        int h=0,m=0,s=0;
        int hh=0,mm=0,ss=0;
        int train_num=1;
        int stock=1;
        int time[10000][2];//?????? ??°???
        
        scanf("%d",&n);
        
        if (n==0) {
            break;
        }
        
        for (i=0; i<n; i++) {
            scanf("%d:%d:%d %d:%d:%d",&h,&m,&s,&hh,&mm,&ss);
            
            //???????¨????
            time[i][0] = h*3600 + m*60 + s;
            time[i][1] = hh*3600 + mm*60 + s;
        }
        
        
        
        
        
        for (i=0; i<DAY; i++) {
            //???????????°????????????????????????
            for (j=0; j<n; j++) {
                if (time[j][1] == i) {
                    //??°?????????
                    stock++;
                }
            }
            
            //???????????????????????????????????????????????°????????§???????????????????????£????????????????¢???????
            for (j=0; j<n; j++) {
                if (time[j][0] == i) {
                    if (stock > 0) {
                        stock--;
                    } else if (stock == 0) {
                        train_num++;
                    }
                }
            }
        }
        
        printf("%d\n",train_num);
    }
    
    return 0;
}