def f(s):

    s=list(map(int,s.split(':')))

    return (s[0]*60+s[1])*60+s[2]

a=86401

while 1:

    t=[0]*a

    n=int(eval(input()))

    if n==0:break

    for _ in range(n):

        b,c=input().split()

        t[f(b)]+=1;t[f(c)]-=1

    d=0

    for i in range(1,a):

        t[i]+=t[i-1]

        d=max(d,t[i])

    print(d)
def f(s):

    return (s[0]*60+s[1])*60+s[2]

a=86400

while 1:

    t=[0]*a

    n=int(eval(input()))

    if n==0:break

    for _ in range(n):

        b,c = [list(map(int,x.split(':'))) for x in input().split()]

        t[f(b)]+=1;t[f(c)]-=1

    d=0

    for i in range(1,a):

        t[i]+=t[i-1]

        if d<t[i]:d=t[i]

    print(d)
def f(s):
    s = list(map(int, s.split(":")))
    return (s[0] * 60 + s[1]) * 60 + s[2]


a = 86401
while 1:
    t = [0] * a
    n = int(eval(input()))
    if n == 0:
        break
    for _ in range(n):
        b, c = input().split()
        t[f(b)] += 1
        t[f(c)] -= 1
    d = 0
    for i in range(1, a):
        t[i] += t[i - 1]
        d = max(d, t[i])
    print(d)

def f(s):
    return (s[0] * 60 + s[1]) * 60 + s[2]


a = 86400
while 1:
    t = [0] * a
    n = int(eval(input()))
    if n == 0:
        break
    for _ in range(n):
        b, c = [list(map(int, x.split(":"))) for x in input().split()]
        t[f(b)] += 1
        t[f(c)] -= 1
    d = 0
    for i in range(1, a):
        t[i] += t[i - 1]
        if d < t[i]:
            d = t[i]
    print(d)

-    s = list(map(int, s.split(":"))) -a = 86401 +a = 86400 -        b, c = input().split() +        b, c = [list(map(int, x.split(":"))) for x in input().split()] -        d = max(d, t[i]) +        if d < t[i]: +            d = t[i]