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

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

int tbl[86400];  // 24*60*60 

char buf[30], *p;
int getint2()
{
	int n;
	n = *p++ & 0xf;
	n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, h, m, s, t, ans;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(tbl, 0, sizeof(tbl));
		n = atoi(buf);
		while (n--) {
			fgets(p=buf, 30, stdin);
			h = getint2(), p++, m = getint2(), p++, s = getint2(), p++;
			t = ((h*60)+m)*60+s, tbl[t]++;

			h = getint2(), p++, m = getint2(), p++, s = getint2();
			t = ((h*60)+m)*60+s, tbl[t]--;
		}
		for (ans = 0, i = 1; i < 86400; i++) {
			tbl[i] += tbl[i-1];
			if (tbl[i] > ans) ans = tbl[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}