#include <stdio.h>

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


