def tosec(t):

    return int(t[:2])*60*60 + int(t[3:5])*60 + int(t[6:])



while True:

    n = int(eval(input()))

    if n == 0: break

    time = [0] * (60*60*24 + 1)



    for _ in range(n):

        s, f = input().split()

        time[tosec(s)] += 1

        time[tosec(f)] -= 1



    ans = time[0]

    for i in range(60*60*24):

        time[i+1] += time[i]

        ans = max(ans, time[i+1])



    print(ans)
while True:

    n = eval(input())

    if not n: break 

    time = [0]*86400

    for i in range(n):

        s, t = input().split()

        ssec = int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8])

        tsec = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6:8])

        time[ssec] += 1

        time[tsec] -= 1

    ans = time[0]

    for i in range(86400-1):

        time[i+1] += time[i]

        ans = max(ans, time[i+1])

    print(ans)



        
def tosec(t):
    return int(t[:2]) * 60 * 60 + int(t[3:5]) * 60 + int(t[6:])


while True:
    n = int(eval(input()))
    if n == 0:
        break
    time = [0] * (60 * 60 * 24 + 1)
    for _ in range(n):
        s, f = input().split()
        time[tosec(s)] += 1
        time[tosec(f)] -= 1
    ans = time[0]
    for i in range(60 * 60 * 24):
        time[i + 1] += time[i]
        ans = max(ans, time[i + 1])
    print(ans)

while True:
    n = eval(input())
    if not n:
        break
    time = [0] * 86400
    for i in range(n):
        s, t = input().split()
        ssec = int(s[0:2]) * 3600 + int(s[3:5]) * 60 + int(s[6:8])
        tsec = int(t[0:2]) * 3600 + int(t[3:5]) * 60 + int(t[6:8])
        time[ssec] += 1
        time[tsec] -= 1
    ans = time[0]
    for i in range(86400 - 1):
        time[i + 1] += time[i]
        ans = max(ans, time[i + 1])
    print(ans)

-def tosec(t): -    return int(t[:2]) * 60 * 60 + int(t[3:5]) * 60 + int(t[6:]) - - -    n = int(eval(input())) -    if n == 0: +    n = eval(input()) +    if not n: -    time = [0] * (60 * 60 * 24 + 1) -    for _ in range(n): -        s, f = input().split() -        time[tosec(s)] += 1 -        time[tosec(f)] -= 1 +    time = [0] * 86400 +    for i in range(n): +        s, t = input().split() +        ssec = int(s[0:2]) * 3600 + int(s[3:5]) * 60 + int(s[6:8]) +        tsec = int(t[0:2]) * 3600 + int(t[3:5]) * 60 + int(t[6:8]) +        time[ssec] += 1 +        time[tsec] -= 1 -    for i in range(60 * 60 * 24): +    for i in range(86400 - 1):