#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	char time[10];
	int depature[10000];
	int arrival[10000];
	int hour, min, sec;
	int cnt;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d:%d:%d", &hour, &min, &sec);
			depature[i] = hour * 3600 + min * 60 + sec;
			
			scanf("%d:%d:%d", &hour, &min, &sec);
			arrival[i] = hour * 3600 + min * 60 + sec;
		}
		
		for (i = 0; i < n - 1; i++){
			if (depature[i] >= 0){
				for (j = i + 1; j < n; j++){
					if (depature[j] >= 0){
						if (arrival[i] <= depature[j]){
							depature[j] = -1;
						}
						else if (arrival[j] <= depature[i]){
							depature[j] = -1;
						}

					}
				}
			}
		}
		
		cnt = 0;
		for (i = 0; i < n - 1; i++){
			if (depature[i] >= 0){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return (0);
}
	