#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll t[20010];
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		rep(i,0,2*n){
			ll a,b,c;
			scanf("%lld:%lld:%lld",&a,&b,&c);
			t[i]=(a*3600+b*60+c)*2+1-i%2;
		}
		sortup(t,2*n);
		ll ans=0,crr=0;
		rep(i,0,2*n){
			if(t[i]%2)crr++;
			else crr--;
			ans=max(ans,crr);
		}
		printf("%lld\n",ans);
	}
}
