// AOJ 2013: Osaki
// 2017.11.1 bal4u@uu
// 2017.12.30

#include <stdio.h>
#include <stdlib.h>

typedef struct { int t; int a; } T;
T tbl[20005]; int sz; 
char buf[30], *p;

int in()
{
	int n;
	n = *p++ & 0xf;
	n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int cmp(T *a, T *b) { return a->t - b->t; }

int main()
{
	int n, h, m, s, ans;
	T *tp;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		tp = tbl;
		sz = n << 1;
		while (n--) {
			fgets(p=buf, 30, stdin);
			h = in(), m = in(), s = in();
			tp->t = (((((h<<6)+m)<<6)+s)<<1)+1, tp->a = 1;
			tp++;

			h = in(), m = in(), s = in();
			tp->t = ((((h<<6)+m)<<6)+s)<<1, tp->a = -1;
			tp++;
		}

		qsort(tbl, sz, sizeof(T), cmp);

		ans = n = 0;
		tp = tbl;
		while (sz--) {
			n += tp->a, tp++;
			if (n > ans) ans = n;
		}
		printf("%d\n", ans);
	}
	return 0;
}