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: import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import accumulate

def time_to_int(x):
    time = ""
    for ch in x:
        if ch == ":":
            continue
        time += ch
    return int(time)

while True:
    n = int(input())

    if n == 0:
        exit()
    data = [0] * (10**6) 

    for i in range(n):
        s,e = input().split()
        int_s = time_to_int(s)
        int_e = time_to_int(e)

        data[int_s] += 1
        data[int_e] -= 1
    data = [0] + data
    cum_data = list(accumulate(data))

    print(max(cum_data))

Python: m=24*60*60
while True:
	n=int(input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
		dp[a*3600+b*60+c]+=1
		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))

Python: def second(hms):
    h, m, s = map(int, hms.split(':'))
    return h * 60 * 60 + m * 60 + s


while True:
    N = int(input())
    if N == 0:
        break
    trains = [0] * 86400
    for _ in range(N):
        start, end = map(second, input().split(' '))
        trains[start] += 1
        trains[end] -= 1

    for i in range(1, len(trains)):
        trains[i] += trains[i - 1]
    print(max(trains))

Python: # https://onlinejudge.u-aizu.ac.jp/problems/2013


def to_my_time_unit(time_str: str):
    hour, minute, second = map(int, time_str.split(sep=':'))
    return int(hour) * 60*60 + int(minute) * 60 + int(second)


def solve(n):
    A = [0 for _ in range(24 * 60 * 60+1)]
    for _ in range(n):
        start_str, end_str = input().split()
        start = to_my_time_unit(start_str)
        end = to_my_time_unit(end_str)
        A[start] += 1
        A[end] -= 1
    B = [0 for _ in range(24 * 60 * 60+1)]
    tmp = 0
    for i in range(24 * 60 * 60+1):
        tmp += A[i]
        B[i] = tmp
    print(max(B))


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        solve(n)

Python: def time_to_sec(time):
    sec = int(time[0:2])*3600
    sec = sec + int(time[3:5])*60
    sec = sec + int(time[6:8])
    return sec


while True:
    timeline = [0] * 86400
    num = int(input())
    if num == 0:
        break
    for i in range(num):
        start,end = input().split()
        start = time_to_sec(start)
        end = time_to_sec(end)
        timeline[start] = timeline[start]+1 
        timeline[end] = timeline[end]-1
    for i in range(1,86400):
        timeline[i] = timeline[i] + timeline[i-1]

    print(max(timeline))

Python: from itertools import accumulate
while 1:
    N = int(input())
    if N==0:
        break
    imos = [0]*24*60*60
    for _ in range(N):
        s, e = input().split()
        S = list(map(int, s.split(':')))
        E = list(map(int, e.split(':')))
        imos[S[0]*60*60+S[1]*60+S[2]] += 1
        imos[E[0]*60*60+E[1]*60+E[2]] -= 1
    IMOS = list(accumulate(imos))
    print(max(IMOS))

Python: from itertools import accumulate

N = int(input())

while N:
  al = [0]*86400
  for i in range(N):
    l,r = input().split()
    hh,mm,ss = map(int,l.split(":"))
    al[hh*3600+mm*60+ss] += 1
    hh,mm,ss = map(int,r.split(":"))
    al[hh*3600+mm*60+ss] -= 1
  print(max(accumulate(al)))
  N = int(input())

Python: def solve(n):
    events = []
    for _ in range(n):
        a, b = input().split()
        events.append((a, 1))
        events.append((b, -1))
    events.append(('99:99:99', 0))
    events.sort(key=lambda event: event[0])
    ans = 0
    tmp = 0
    prev = None
    for e, d in events:
        if prev != e:
            ans = max(ans, tmp)
        tmp += d
        prev = e
    print(ans)

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

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break

        a = [LS() for _ in range(n)]
        b = []
        for s,e in a:
            b.append((s,1))
            b.append((e,-1))
        b.sort()
        r = c = 0
        for t,f in b:
            c += f
            if r < c:
                r = c

        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())