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)
}

C++: // Osaki
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        int time[86500] = {};
        rep(i, n){
            int hh1, mm1, ss1;
            int hh2, mm2, ss2;
            scanf("%d:%d:%d", &hh1, &mm1, &ss1);
            scanf("%d:%d:%d", &hh2, &mm2, &ss2);
            int t1 = hh1 * 3600 + mm1 * 60 + ss1;
            int t2 = hh2 * 3600 + mm2 * 60 + ss2;
            time[t1]++;
            time[t2]--;
        }
        int ans = 0;
        rep(i, 86450){
            time[i+1] = time[i+1] + time[i];
        }
        rep(i, 86450){
            ans = max(ans, time[i]);
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
int r[90001], n, h1, m1, s1, h2, m2, s2;
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break;
		for (int i = 0; i <= 90000; i++) r[i] = 0;
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d %02d:%02d:%02d", &h1, &m1, &s1, &h2, &m2, &s2);
			r[h1 * 3600 + m1 * 60 + s1]++;
			r[h2 * 3600 + m2 * 60 + s1]--;
		}
		int ret = 0, sum = 0;
		for (int i = 0; i <= 90000; i++) {
			sum += r[i];
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

C++: #include<cstdio>
#include<vector>
using namespace std;

const int lim = 24*60*60;

inline int t(int h, int m, int s){
  return h*60*60 + m*60 + s;
}

int main(){
  int n;
  while(scanf("%d",&n)){
    if(n==0)break;

    vector<int> x(lim+1,0);
    for(int i=0;i<n;i++){
      int h1,m1,s1, h2,m2,s2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);

      x[t(h1,m1,s1)]++;
      x[t(h2,m2,s2)]--;
    }

    int ans = 0, cur = 0;
    for(int i=0;i<=lim;i++){
      cur += x[i];
      ans = max(ans, cur);
    }
    printf("%d\n",ans);
  }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 10000
#define TOSEC(h,m,s) ((h)*3600+(m)*60+(s))
struct Train{
	int st;
	int ed;
	bool operator<(const Train &t)const{
		return ed > t.ed;
	}
};
bool CompTrainForSort(const Train &a, const Train &b){
	return a.st < b.st;
}
int main(){
	/*priority_queue<int> test;
	test.push( 100 );
test.push( 101 );
test.push( 102 );
test.push( 103 );
test.push( 10 );
test.push( 49 );

cout << test.top() << endl;*/

	while(true){
		Train vt[MAX];
		unsigned int ans = 0;
		int n;
		priority_queue< Train > pq;
		scanf("%d", &n);

		if( n == 0 ) break;

		for(int i = 0; i < n; ++i){
			int sh,sm,ss;
			int eh,em,es;
			Train t;
			
			scanf("%02d:%02d:%02d %02d:%02d:%02d",
				&sh,&sm,&ss,
				&eh,&em,&es);
			t.st = TOSEC(sh,sm,ss);
			t.ed = TOSEC(eh,em,es);

			vt[i] = t;
		}

		sort( vt, vt + n, CompTrainForSort );
		
		for(int i = 0; i < n; ++i){
			if( pq.size() == 0 )
				pq.push( vt[i] );
			else{
				Train tt = pq.top();
				if( tt.ed <= vt[i].st ){
					pq.pop();
					pq.push( vt[i] );
				}else{
					pq.push( vt[i] );
				}
			}
			ans = max(ans, pq.size());
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ma=0;
    int time_table[30][65][65];
    for(int i=0;i<n;i++){
      int a,b,c;
      scanf("%d:%d:%d",&a,&b,&c);
      time_table[a][b][c]++;
      scanf("%d:%d:%d",&a,&b,&c);
      time_table[a][b][c]--;
    }
    int cnt=0;
    for(int i=0;i<=24;i++){
      for(int j=0;j<=60;j++){
	for(int k=0;k<=60;k++){
	  cnt+=time_table[i][j][k];
	  ma=max(ma,cnt);
	}
      }
    }
    cout<<ma<<endl;
  }
  return 0;
}