Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		accum := make([]int, 86401)
		for i := 0; i < n; i++ {
			s, e := io.Next(), io.Next()
			hs, _ := strconv.Atoi(s[:2])
			ms, _ := strconv.Atoi(s[3:5])
			ss, _ := strconv.Atoi(s[6:8])
			accum[hs*60*60+ms*60+ss]++
			he, _ := strconv.Atoi(e[:2])
			me, _ := strconv.Atoi(e[3:5])
			se, _ := strconv.Atoi(e[6:8])
			accum[he*60*60+me*60+se]--
		}
		ans := 0
		for i := 1; i < 86401; i++ {
			accum[i] += accum[i-1]
			ans = intMax(accum[i], ans)
		}
		io.Println(ans)
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    while 1:
        n = I()
        if n == 0:
            break
        m = 24*60**2
        a = [0]*m
        for i in range(n):
            l,r = input().split()
            l = list(map(int, l.split(":")))
            r = list(map(int, r.split(":")))
            l = l[2]+60*(l[1]+60*(l[0]))
            r = r[2]+60*(r[1]+60*(r[0]))
            a[l] += 1
            a[r] -= 1
        for i in range(m-1):
            a[i+1] += a[i]
        print(max(a))
    return

#Solve
if __name__ == "__main__":
    solve()

Python: 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(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)

Python: INF=10**5
while True:
  n=int(input())
  if n==0:break
  imos=[0 for i_ in range(INF)]
  for _ in range(n):
    a,b=input().split()
    s1=list(map(int,a.split(':')))
    s2=list(map(int,b.split(':')))
    s1=s1[0]*3600+s1[1]*60+s1[2]
    s2=s2[0]*3600+s2[1]*60+s2[2]
    imos[s1]+=1
    imos[s2]-=1
  for i in range(INF-1):
    imos[i+1]+=imos[i]
  print(max(imos))

Python: # 山手線は34.5Km
# 一周一時間かかる
# 駅は29駅ある
import itertools
while True:
    n = int(input())  # n <= 10000
    if n == 0:
        break
    timestamps = [0 for _ in range(24 * 60 * 60 + 1)]
    for _ in range(n):
        start, end = input().split()
        start_h, start_m, start_s = map(int, start.split(":"))
        start_h = start_h * 60 * 60
        start_m = start_m * 60
        start_time = start_h + start_m + start_s
        end_h, end_m, end_s = map(int, end.split(":"))
        end_h = end_h * 60 * 60
        end_m = end_m * 60
        end_time = end_h + end_m + end_s
        timestamps[start_time + 1] += 1
        timestamps[end_time + 1] -= 1
    timestamps = list(itertools.accumulate(timestamps))
    print(max(timestamps))

Python: from itertools import accumulate
HR_IN_DAY = 24; MIN_IN_HR = 60;  SEC_IN_MIN = 60

while True:
    n = int(input())
    if n == 0: break
    train = [0] * HR_IN_DAY * MIN_IN_HR * SEC_IN_MIN
    for i in range(n):
        depart, arrive = [t.split(':') for t in input().split(' ')]
        d_hr, d_min, d_sec = map(int, depart)
        a_hr, a_min, a_sec = map(int, arrive)
        train[d_hr * MIN_IN_HR * SEC_IN_MIN + d_min * SEC_IN_MIN + d_sec] += 1
        train[a_hr * MIN_IN_HR * SEC_IN_MIN + a_min * SEC_IN_MIN + a_sec] -= 1

    train = accumulate(train)
    print(max(train))

Python: # AOJ_osaki.py
def calc_imos(one_day):
    day = []
    cum_sum = 0
    for i in one_day:
        cum_sum += i
        day.append(cum_sum)
    return max(day)

def calc_time(time):
    h,m,s = map(int,time.split(":")) 
    return h*60*60 + m*60 + s

while True:
    N = int(input())
    if N==0:break
    one_day = [0]*(24*60*60+1) # 秒数で1日を管理する
    for i in range(N):
        start, end = input().split()
        # 時間を1日の秒数に直す
        # one_dayに累積和を登録していく
        start = calc_time(start)
        end = calc_time(end)
        one_day[start+1] += 1
        one_day[end+1] -= 1
    print(calc_imos(one_day))
# 累積和を計算して本数を計算する

Python: MAX = 24*60**2 + 60*60 + 60

def datetime2second(datetime):
    hours, minutes, seconds = map(int, datetime.split(':'))

    return hours * 60**2 + minutes * 60 + seconds

while True:
    n = int(input())
    if n == 0: break

    s = [0] * (MAX + 1)
    for i in range(n):
        d, a = map(datetime2second, input().split())

        s[d] += 1
        s[a] -= 1
    
    ans = s[0]
    for i in range(MAX):
        s[i+1] += s[i]
        ans = max(ans, s[i+1])

    print(ans)

Python: import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

for _ in range(10 ** 9):
    n = int(input())
    if n == 0:
        break
    hs = [0 for _ in range(24 * 60 * 60 + 2)]
    for i in range(n):
        start, end = map(str, input().split())
        start = [int(start[0:2]), int(start[3:5]), int(start[6:8])]
        end = [int(end[0:2]), int(end[3:5]), int(end[6:8])]
        hs[start[0] * 60 * 60 + start[1] * 60 + start[2]] -= 1
        hs[end[0] * 60 * 60 + end[1] * 60 + end[2]] += 1
    hs = list(itertools.accumulate(hs))
    print(abs(min(hs)))

Python: def cvtTime(s):
    h, m, s = map(int, s.split(":"))
    return h * 60 * 60 + m * 60 + s


while True:
    n = int(input())
    if n == 0:
        break

    cnt = [0] * (60 * 60 * 24 + 2)

    for i in range(n):
        begin, end = input().split()
        begin_time = cvtTime(begin)
        end_time = cvtTime(end)

        cnt[begin_time] += 1
        cnt[end_time] -= 1

    for i in range(1, len(cnt)):
        cnt[i] += cnt[i - 1]

    print(max(cnt))